"String" Case Question

M

Magic Speller

Hi eveyone,

New to the newsgroup -- so here's a simple newbie question for you.
I'm sure this has been answered many times, but I have no idea how to
search for the answer.

Can someone explain to me the difference between declaring a string
using "string" or "String"? For example:

string string1 = "Hello"
String string1 = "Hello"

I know the convention is to use the lowercase version, but the
uppercase version seems to work in the same way. Are there
differences, and what are the relative advantages and disadvantages,
or implications, of using one or the other?

Thanks!
 
A

Arne Vajhøj

New to the newsgroup -- so here's a simple newbie question for you.
I'm sure this has been answered many times, but I have no idea how to
search for the answer.

Can someone explain to me the difference between declaring a string
using "string" or "String"? For example:

string string1 = "Hello"
String string1 = "Hello"

I know the convention is to use the lowercase version, but the
uppercase version seems to work in the same way. Are there
differences, and what are the relative advantages and disadvantages,
or implications, of using one or the other?

No difference. Not ever. Not anywhere.

The C# spec state:

<quote>
The keyword string is simply an alias for the predefined class
System.String.
</quote>

I assume that next question will be: why two.

..NET was designed to support multiple languages, so .NET comes
with a complete language independent set of types. For
string type that is System.String.

Language implementations targeting .NET, then maps its
builtin types to the .NET types.

Examples:

VB.NET maps Integer->System.Int32 and String->System.String
C++ maps int->System.Int32 and does not map std::string (different
semantics)
Delphi.NET maps integer->System.Int32, string->System.String
A# aka MGNAT maps Integer->System.Int32 and does not map
Unbounded_String (different semantics)

C# maps int->System.Int32 and string->System.String, but C# is
different from the above languages. In the above languages
it is an implementation decision how to map. In C# it is specified
in the spec for the language.

Arne
 

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