String v. string

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Could someone explain why there is a Datatype (Class) called String, and a
static class string that has methods of it's own? Is String the instance
class and string is the static class??

Thanks in advance.

Mark
 
Mark said:
Could someone explain why there is a Datatype (Class) called String,
and a static class string that has methods of it's own? Is String
the instance class and string is the static class??

string is a C# wrapper for the CLR's System.String class. As for
instance vs. static, a class is neither. string can be instantiated
*and* it has static methods.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
Mark,
"String" is the name of the System.String class.

While "string" is C#'s alias for the System.String class. Which means they
are both refer to exactly the same class.

In other words:

Debug.Assert(typeof(string) == typeof(System.String), "must be true!");

Hope this helps
Jay
 
Avlin,

You are correct, "string" in C# is just an alias for System.String.
What one sees as static on "string" can also be accessed through
"System.String" in the same manner (same methods, etc, etc).

Hope this helps.
 
Can you stop posting that picture, we have limited usage here and everything is logged, I think everyone has seen it by now.
 
Back
Top