Click here to Skip to main content
15,891,513 members
Home / Discussions / C#
   

C#

 
AnswerRe: error in bool condition ? Pin
Dario Solera1-Jul-05 23:52
Dario Solera1-Jul-05 23:52 
AnswerRe: error in bool condition ? Pin
Robert Rohde2-Jul-05 0:04
Robert Rohde2-Jul-05 0:04 
GeneralRe: error in bool condition ? Pin
fracalifa2-Jul-05 0:29
fracalifa2-Jul-05 0:29 
AnswerRe: error in bool condition ? Pin
User 66582-Jul-05 1:03
User 66582-Jul-05 1:03 
GeneralRe: error in bool condition ? Pin
fracalifa2-Jul-05 1:10
fracalifa2-Jul-05 1:10 
GeneralRe: error in bool condition ? Pin
User 66582-Jul-05 6:21
User 66582-Jul-05 6:21 
GeneralRe: error in bool condition ? Pin
fracalifa2-Jul-05 6:45
fracalifa2-Jul-05 6:45 
GeneralRe: error in bool condition ? Pin
User 66582-Jul-05 7:52
User 66582-Jul-05 7:52 
this is strange indeed, looks like the && operator is evaluated BEFORE the || operator - I thought they are handled equally.
If you want the || clause to be evaluated before, better put brackets around the first two expressions.
This is a test I made:

			string a = "MR";
			string b = "MRS";
			string c = "BAKER";
			string d = "Meyers";

			bool b1,b2,b3,b4,b5;

			b1 = string.Equals(a.TrimEnd().TrimStart().ToString().ToUpper(),"MR");
			b2 = string.Equals(b.TrimEnd().TrimStart().ToString().ToUpper(),"MRS");
			b3 = string.Equals(a.TrimEnd().TrimStart().ToString().ToUpper(),"MRS");
			b4 = string.Equals(b.TrimEnd().TrimStart().ToString().ToUpper(),"MR");
			b5 = string.Equals(c.TrimEnd().TrimStart().ToString().ToUpper(), d.TrimEnd().TrimStart().ToString().ToUpper());

			bool b6, b7;

			b6 = (((b1 && b2) || (b3 && b4)) && b5); // FALSE
			b7 = ((b1 && b2) || ((b3 && b4) && b5)); // TRUE

//			if((b1 && b2) || (b3 && b4) && b5)
			if(b6)
			{
				MessageBox.Show("ERROR");
			}


regards

/edit:
This supports my theory:
Operator precedence and associativity

modified 12-Sep-18 21:01pm.

GeneralRe: error in bool condition ? Pin
Niklas Ulvinge3-Jul-05 2:53
Niklas Ulvinge3-Jul-05 2:53 
QuestionHow to find relation between user , process created by him and his session Pin
rajee.nedunchezian1-Jul-05 23:37
rajee.nedunchezian1-Jul-05 23:37 
AnswerRe: How to find relation between user , process created by him and his session Pin
Dario Solera1-Jul-05 23:48
Dario Solera1-Jul-05 23:48 
Generalpopulating datagrid with array of objects Pin
deep71-Jul-05 23:34
deep71-Jul-05 23:34 
GeneralChanging Regional Language of a TextBox Pin
Ali Beirami1-Jul-05 23:01
Ali Beirami1-Jul-05 23:01 
GeneralSend a click to an application Pin
Dario Solera1-Jul-05 21:15
Dario Solera1-Jul-05 21:15 
GeneralAdding Help in a software Pin
asmyan1-Jul-05 21:06
asmyan1-Jul-05 21:06 
GeneralRe: Adding Help in a software Pin
Ashok Dhamija1-Jul-05 21:10
Ashok Dhamija1-Jul-05 21:10 
GeneralRe: Adding Help in a software Pin
Dario Solera1-Jul-05 23:55
Dario Solera1-Jul-05 23:55 
GeneralThreads and System.Timers.Timer - Problems Pin
stan281-Jul-05 20:41
stan281-Jul-05 20:41 
GeneralRe: Threads and System.Timers.Timer - Problems Pin
S. Senthil Kumar1-Jul-05 21:22
S. Senthil Kumar1-Jul-05 21:22 
GeneralRe: Threads and System.Timers.Timer - Problems Pin
stan283-Jul-05 7:37
stan283-Jul-05 7:37 
GeneralRe: Threads and System.Timers.Timer - Problems Pin
leppie2-Jul-05 6:47
leppie2-Jul-05 6:47 
GeneralRe: Threads and System.Timers.Timer - Problems Pin
stan283-Jul-05 7:40
stan283-Jul-05 7:40 
GeneralPlz Help on Net Send Pin
Member 122691721-Jul-05 19:18
Member 122691721-Jul-05 19:18 
GeneralRe: Plz Help on Net Send Pin
Dario Solera1-Jul-05 23:40
Dario Solera1-Jul-05 23:40 
GeneralIntegration of Window Service and my project through set up program Pin
ksanju10001-Jul-05 19:09
ksanju10001-Jul-05 19:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.