String vs string

G

Guest

I am curious about declaring strings in C#. I see strings declared like:
string mystring = "something";
I also see:
String mystring = "something";

What is the difference?
 
T

Tim Wilson

In C#, "string" is a keyword alias for System.String. So they are the same
thing.
 
L

Ludwig Stuyck

I am curious about declaring strings in C#. I see strings declared like:
string mystring = "something";
I also see:
String mystring = "something";

What is the difference?

string is an alias of String.... there's no difference!
 
J

Joerg Jooss

Robert said:
I am curious about declaring strings in C#. I see strings declared
like: string mystring = "something";
I also see:
String mystring = "something";

What is the difference?

Short answer: No difference.

Long answer:
The actual class name in the BLC is System.String. "string" a C#
language keyword that is mapped to System.String, just like "int" is
mapped to System.Int32, or "object" is mapped to System.Object.

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top