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 8616347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:35:50+00:00 2026-06-12T05:35:50+00:00

I am wondering if the following expressions are equivalent (In C#): float x =

  • 0

I am wondering if the following expressions are equivalent (In C#):

float x = ... ;
int y = ... ;

var result = (float) (x / y);

Versus:

var result = x / (float)y;

Where can i read more about this specific topic?

What i am interested in is:

  1. Will these always produce the same result?
  2. Does one option perform more efficiently than the other?
  • 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-06-12T05:35:52+00:00Added an answer on June 12, 2026 at 5:35 am

    Yes, they will behave the same way. In fact, you can just use:

    var result = x / y;
    

    or

    float result = x / y;
    

    Section 7.8.2 of the C# 4 spec shows which division operators are avaiable – and there’s no float operator /(float, int) operator. Instead, the C# compiler uses the implicit conversion from int to float, and uses the float operator /(float, float) operator.

    This is just normal operator overload resolution (spec section 7.3.4) and implicit numeric conversions (spec section 6.1.2).

    When in doubt consult the spec. I have a web page with links to the different versions; the C# 5 spec is bundled with VS 2012 but there’s no separate download for it right now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just wondering if the following expressions used for Value are equivalent (the column Contrib
I really don't understand regular expressions and was wondering what the following regular expressions
I'm new to some of App Development and was wondering the following; How can
Are the following Lambda and Linq expressions equivalent in terms of execution paths? I
I'm in the process of trying to learn more about regular expressions and I've
I was wondering which of the following LINQ expressions is better (especially in terms
I have the two following regular expressions and I am wondering what reason there
Wondering if anyone out there can shed some light on why the following regular
Wondering if following will work for google in robots.txt Disallow: /*.action I need to
Just wondering if the following is considered to be good programming practice or not?

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.