© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
26 replies
exove

❔ Need help explaining precedence in C#

int x = 10;
int y = 20;
x += y += y = 5;
Console.WriteLine(x) //Output 35
int x = 10;
int y = 20;
x += y += y = 5;
Console.WriteLine(x) //Output 35

Why is the above code does it evaluate to 35?
Why is it not
y = 5
y += y // 10
x += y // 20
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

need help in C#
C#CC# / help
4mo ago
need help in c@
C#CC# / help
4mo ago
✅ need help in c#
C#CC# / help
17mo ago
✅ Need C# help
C#CC# / help
4mo ago