472,990 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,990 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 22482
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.