471,123 Members | 849 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,123 software developers and data experts.

What is the difference between String and string in C#?

What is the difference between String and string in C#?
What can u do with string that you cant do with String, vice versa?
Aug 3 '06 #1
7 22380
Bruce One wrote:
What is the difference between String and string in C#?
"string" is a keyword; you can't use "string" as an identifier.
"String" is not a keyword, and you can use it as an identifier:

string String = "Isn't this confusing?";

That's the only difference. The keyword "string" is an alias for
"System.String"; aside from the keyword issue, the two are exactly
equivalent. typeof(string) == typeof(String) == typeof(System.String).

--

..NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
Delphi skills make .NET easy to learn In print, in stores.
Aug 4 '06 #2
Bruce One <ra**@virtualsoftware.com.brwrote:
What is the difference between String and string in C#?
What can u do with string that you cant do with String, vice versa?
string is just a shorthand for String. There is no difference
whatsoever in capabilities.

(There's a very slight difference in terms of hoops you need to go
through if you want to name a variable "string", but I suggest you
don't create variables called either String or string.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 4 '06 #3
Thanks to all !
Aug 4 '06 #4

No difference.

--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Aug 5 '06 #5

Why should not create using system? If it has the same result as
System.String and its pretty quicker, why not?

"Jon Skeet [C# MVP]" wrote:
Bruce One <ra**@virtualsoftware.com.brwrote:
What is the difference between String and string in C#?
What can u do with string that you cant do with String, vice versa?

string is just a shorthand for String. There is no difference
whatsoever in capabilities.

(There's a very slight difference in terms of hoops you need to go
through if you want to name a variable "string", but I suggest you
don't create variables called either String or string.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 5 '06 #6

Why should not create using string (lowercase) ? If it has the same result
as System.String and its pretty quicker, why not?

"Jon Skeet [C# MVP]" wrote:
Bruce One <ra**@virtualsoftware.com.brwrote:
What is the difference between String and string in C#?
What can u do with string that you cant do with String, vice versa?

string is just a shorthand for String. There is no difference
whatsoever in capabilities.

(There's a very slight difference in terms of hoops you need to go
through if you want to name a variable "string", but I suggest you
don't create variables called either String or string.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 5 '06 #7
Bruce One <ra**@virtualsoftware.com.brwrote:
Why should not create using string (lowercase) ? If it has the same result
as System.String and its pretty quicker, why not?
I'm not sure what you mean by "create using string"?

I certainly tend to use the C# shorthands rather than the full type
names (eg float instead of Single) but it sounds like you're proposing
something slightly different...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 5 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by diadia | last post: by
1 post views Thread by Leigh Finch | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.