| | |
string and String
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
•
•
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.
C# Syntax (Toggle Plain Text)
String a = "Hello World";
Whereas this line of code would compile whether or not "using System" is in your code or not.
C# Syntax (Toggle Plain Text)
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.
•
•
•
•
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?
Reguards,
Tyler S. Breton
![]() |
Similar Threads
Other Threads in the C# Forum
- Previous Thread: Question about .Row.Add(new object[]{...,...}) Please help!
- Next Thread: Threading Issue
| Thread Tools | Search this Thread |
.net access ado.net algorithm angle array barchart bitmap box broadcast buttons c# capturing check checkbox client color combobox control conversion convert csharp custom database datagrid datagridview dataset datetime degrees delegate development disappear draganddrop drawing encryption enum event excel file form format forms function gdi+ geometry httpwebrequest image index input install java label leak list listbox mandelbrot math monodevelop mouseclick msword mysql operator path pause photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox round serialization server sleep socket sql statistics stream string table text textbox thread time timer update usercontrol validation virtualization visualbasic visualstudio webbrowser windows winforms wpf xml





