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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:08:02+00:00 2026-05-23T22:08:02+00:00

class Program { private static bool _ret = true; static void Main() { _ret

  • 0
class Program
{
    private static bool _ret = true;

    static void Main()
    {
        _ret &= Method();
        Console.WriteLine(_ret);
        Console.Read();
    }

    private static bool Method()
    {
        _ret &= false;
        return true;
    }
}

We came across this issue in a larger application we are developing and was wondering if it was expected functionality? This is written in c# with Visual Studio 2010

  • 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-23T22:08:02+00:00Added an answer on May 23, 2026 at 10:08 pm

    As explained by Eric Lippert in his blog post “Precedence vs Associativity vs Order”,

    The expression F() + G() * H() is equivalent to F() + (G() * H()), but
    C# does NOT evaluate G() * H() before F(). Rather, this is equivalent
    to:

    temp1 = F();

    temp2 = G();

    temp3 = H();

    temp4 = temp2 * temp3;

    result = temp1 + temp4;

    So in your case, it evaluates _ret prior to calling Method(), and the fact that _ret changes inside Method() does not affect the outer call.

    See: http://blogs.msdn.com/b/ericlippert/archive/2008/05/23/precedence-vs-associativity-vs-order.aspx

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

Sidebar

Related Questions

class Program { static void Main(string[] args) { String value = Two; Type enumType
class Program { static void Main(string[] args) { List<Book> books = new List<Book> {
class Program { internal delegate int CallBack(int i); static void Main(string[] args) { CallBack
Consider the following code: class Program { static void Main(string[] args) { Department deathStar
Take the following useless program: class Program { static void Main(string[] args) { IUnityContainer
I have the following code: class Program { static void Main(string[] args) { new
copy paste the following code in new C# console app. class Program { static
My program has the following class definition: public sealed class Subscriber { private subscription;
Suppose I've got the following program: namespace ReflectionTest { public class Example { private
Is this the best approach to handle both cases ? public static class Program

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.