How do u find out if 2 strings are the same in c#?
Do you mean have the same contents, or the same reference?
Contents:
string hello1 = "Hello";
string hello2 = "Hello";
Console.WriteLine((hello1==hello2) + "");
should give you true (or 1, whatever, can't remember what .net gives us again)
but
Console.WriteLine(object.ReferenceEquals(hello1,he llo2) + "");
may give you false because it checks to see if hello1 and hello2 are referencing the same object in memory.
I think in this case both return true because of the way the compiler deals with constant strings... but it's easy to image a situation where it wouldn't
-mwalts