Saturday, March 31, 2012

String vs. string in C#

Ok...

what's the difference? If I have functions like this...

public string foo(string bar)
{
}

public String foo(String bar)
{
}

I get an error saying that they are the same function... actually it says that foo is already defined, but..., so they must be equivalent. So, why do they both exist? Why does code code completion give you the capitalized version, but syntax hilighting recognizes the lowercase?Hi,

they are one and the same. Lowercase 'string' is C# shortcut/specific to System.String (the capitalized one e.g 'String').

0 comments:

Post a Comment