Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6102837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:39:37+00:00 2026-05-23T13:39:37+00:00

I am learning C# and keep getting an error Cannot implicitly convert type ‘int’

  • 0

I am learning C# and keep getting an error “Cannot implicitly convert type ‘int’ to ‘short'”.

In Microsoft SQL Server where my database is, U_Weeks_In_Month is defined as smallint. What do I need to do to solve this error?

I tried to use short.Parse just like in the year textfields but this does not work for the item, i.e

U_Weeks_In_Month = short.Parse(item.WeekNumber),

Any solution?

My code is :

var weekInfos = SAPUtility.GetWeekInfo(dateTimePicker1.Value, 52);

// Create object
foreach (var item in weekInfos)
{
    // Get new code
    var newWeeklyCode = weeklyPeriodService.GenerateSAPCode();

    var weeklyPeriodAdd =
        new WeeklyPeriod
        {
            Code = newWeeklyCode,
            Name = newWeeklyCode,
            U_Tax_Year = short.Parse(txt_tax_year.Text),
            U_Month = item.Month.ToString(),
            U_Pay_Process_Status = "N",
            U_Payroll_Year = short.Parse(txt_tax_year.Text),
            U_Weeks_In_Month = item.WeekNumber,
            U_Starting_date = item.FirstDayOfWeek,
            U_Ending_date = item.LastDayOfWeek,
        };

    // Save record
    weeklyPeriodService.AddWeeklyPeriod(weeklyPeriodAdd);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:39:38+00:00Added an answer on May 23, 2026 at 1:39 pm

    I suspect you just need:

    U_Weeks_In_Month = (short) item.WeekNumber
    

    An alternative is to change your WeekNumber property to short to start with.

    Additionally, I’d pull the parsing of txt_tax_year.Text outside the loop:

    short taxYear = short.Parse(txt_tax_year.Text);
    foreach (var item in weekInfos)
    {
        // Use taxYear in here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SQL Syntax is still something I am learning. I am getting the error noted
Hey, I am Just Learning CoffeeScript and I Keep getting Errors. Here is my
I'm learning objective-c and keep bumping into the @ symbol. It is used in
Learning a little about T-SQL, and thought an interesting exercise would be to generate
I'm learning about table design in SQL and I'm wonder how to create a
I have been slowly learning iPhone development and seem to keep hitting walls where
I'm writing a simple HTTP server and learning about TIME_WAIT. How do real web
In our Learning Management System someone in their infinite wisdom decided to keep non-standardized
Learning WPF nowadays. Found something new today with .Net dependency properties. What they bring
Learning from my last question , most member names seem to get included in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.