j_tipps
asked on
if (string = string) error converting string to bool
I'm from a vb.net back ground and not sure how to compaire two string values in a if statement.
I know that in c# that if statements always return a boolen value and thats fine but i just want to make sure two string have the save value.
I know that in c# that if statements always return a boolen value and thats fine but i just want to make sure two string have the save value.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
in C#? Remember strings are objects. You can type:
if( myStr1.Equals( myStr2 ) ) { ... }
Which I believe is exactly the same
if( myStr1 == myStr2 ) { ... }
but clear in the sense that you are asking the myStr1 object to tell you whether myStr2 represents the same object.
This works for any object, not just strings.
Dave
if( myStr1.Equals( myStr2 ) ) { ... }
Which I believe is exactly the same
if( myStr1 == myStr2 ) { ... }
but clear in the sense that you are asking the myStr1 object to tell you whether myStr2 represents the same object.
This works for any object, not just strings.
Dave
ASKER
ya thansk for the 411 Dave!
ASKER