[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

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.
0
j_tipps
Asked:
j_tipps
  • 2
1 Solution
 
Rodney HelsensCommented:
are you using the double == for comparison

if (string == string)

not

if (string = string), which is assignment..
0
 
j_tippsAuthor Commented:
oo crap that was it, thanks man
0
 
dcgamesCommented:
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
0
 
j_tippsAuthor Commented:
ya thansk for the 411 Dave!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now