string and String

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2006
Posts: 8
Reputation: foo is an unknown quantity at this point 
Solved Threads: 0
foo foo is offline Offline
Newbie Poster

string and String

 
0
  #1
Nov 8th, 2006
What is the difference between string and String?
If I want
string name = "Joe";
String name = "Joe";

which is the correct usage? Is there a difference?
Thanks in advance.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 89
Reputation: TylerSBreton is an unknown quantity at this point 
Solved Threads: 3
TylerSBreton's Avatar
TylerSBreton TylerSBreton is offline Offline
Junior Poster in Training

Re: string and String

 
1
  #2
Nov 10th, 2006
Originally Posted by foo View Post
What is the difference between string and String?
If I want
string name = "Joe";
String name = "Joe";

which is the correct usage? Is there a difference?
Thanks in advance.
Well, "string" is actually an object type of the System.String class. So if you omit "using System" from your program, this will not compile:

  1. String a = "Hello World";

Whereas this line of code would compile whether or not "using System" is in your code or not.
  1. string a = "Hello World";

Think of string as a "shortcut" to the System.String class whereas String is basically directly making a variable of type System.String when "using System" is in the program.

(string == System.String)

Reguards,

Tyler S. Breton
Last edited by TylerSBreton; Nov 10th, 2006 at 2:42 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 8
Reputation: foo is an unknown quantity at this point 
Solved Threads: 0
foo foo is offline Offline
Newbie Poster

Re: string and String

 
0
  #3
Nov 10th, 2006
Thanks for replying.
So basically, I can use either or as long as I pay attention to whether using System. Using System is automatically added into new projects. I wonder, when would you not using System?
There's no advantage then of using String over string or is there?
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 89
Reputation: TylerSBreton is an unknown quantity at this point 
Solved Threads: 3
TylerSBreton's Avatar
TylerSBreton TylerSBreton is offline Offline
Junior Poster in Training

Re: string and String

 
0
  #4
Nov 10th, 2006
Originally Posted by foo View Post
Thanks for replying.
So basically, I can use either or as long as I pay attention to whether using System. Using System is automatically added into new projects. I wonder, when would you not using System?
There's no advantage then of using String over string or is there?
There is no advantage. string == System.String.

Reguards,

Tyler S. Breton
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC