C#: string vs. String

liunx

Guest
So, I'm flipping through my ADO.NET Cookbook (O'Reilly) and they always use String when they need a string variable.

Back in my good ole days of JAVA, we had two different datatypes for string variables: regular old string and String (which was an object with a bit more functionality)

Is that the case with C#, and if so what all differences are there between the two: string and String.

ThanksThere are no differences.

The name "string" is an intrinsic type that is mapped to "String" class.so there's no benefit to using either over the other?

other than the blue-erization of the text when you use lowercase, maybe?That is correct. Its better to use the lower case unless you do not want the variable colored.

But you can still reach non-static member functions with either and static methods are can still be called with either. Its just mapped as it was the left over from C++ CString but more common in java to use string data type.check this article out, i found it very helpful. it's a 10-page article that explains all of the nuances in an easy to understand format.

<!-- m --><a class="postlink" href="http://en.csharp-online.net/CSharp_String_Theory">http://en.csharp-online.net/CSharp_String_Theory</a><!-- m -->

"a string is a sequential collection of Unicode characters that represents text, a String object is a sequential collection of System.Char objects that represents a string"
ref: WikiSysop's CSharp String TheoryThis was already covered in our discussion, that there was no difference between the two.


You can use them interchangeably in your code


You might also want to look at the date of the thread, its almost 2 years old.

The only difference in VS.net is the color coding when using the type.
 
Back
Top