473,394 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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 22500
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: diadia | last post by:
string s = "hello"; const char *p = s.begin(); cout << p << endl; // print hello s = ""; char *p2= s.begin(); cout << p2 << endl; // print hello why?????
7
by: herrcho | last post by:
i'm in the course of learning C, and found these two words "string, string literal" confusing me.. I'd like to know the difference between them.. Thank you
3
by: Green | last post by:
Hi, I am reading about an article of user control at the following site: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconexposingpageletproperties.asp and i...
5
by: Martin Jørgensen | last post by:
Hello again, Sorry to bother but I guess my C++ book isn't very good since it obviously contains errors so the program code doesn't work with g++. However I don't understand what the problem...
2
by: Steve Richter | last post by:
KeyValuePair<string,stringhas a ToString method that returns the KeyValue pair seperated by a comma and enclosed in : Is this method used as a building block for serialization? The reason I...
5
by: bhushanbagul | last post by:
Hi All Please let me know exactly what difference i and g makes in oracle version i.e. when we say oracle 10g or oracle 11i Thanks Bhushan
1
by: DR | last post by:
how to determine what language a string is written in? is there any method to take a string and return what language it is in? e.g. english, hindi, spanish, etc.
1
by: Leigh Finch | last post by:
Hey Guys, Quick question about the PHP compiler, is there any performance difference between $string .= $new; and $string = $string . $new;
1
by: gilit golit | last post by:
HI ! I am expirienced C++ programmer , but new to C# 1. What is the difference between string and String ? when is each one used ? 2. I tried to use "ToCharArray" , because I need the text in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.