Hey buddies!
Is there any difference between String and string. If any, please post it here.... :)
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Jul 28, 2011, 12:03 PM
Try this. Create a new Console applicaiton. Remove all the "Using" statements at the top. Then put the following in the Main:
String s2 = "Hello";
You will get an error for s2 but not s1, because s1 is an alias for "System.String". That means that you do not need a Using for it but you do need either a Using for "String" or without a Using you need to specify System.String. Note that "string" is an alias for System.String and since you are not likely to ever write a program without a Using for System, Vulpes's and John's replies are correct.
Manikavelu VelayuthamPosted Jul 29, 2011, 7:27 AM
VulpesPosted Jul 29, 2011, 6:00 AM
Manikavelu VelayuthamPosted Jul 29, 2011, 5:38 AM
VulpesPosted Jul 29, 2011, 5:26 AM
string -> String
int -> Int32
long -> Int64
double -> Double
float -> Single
This was done so that C# would seem more familiar to C/C++/Java programmers and to give the C# language some character of its own compared to other .NET languages.
However, whether you use the C# keywords or the .NET Framework types is a matter of taste and some developers prefer to use the latter.
Manikavelu VelayuthamPosted Jul 29, 2011, 5:05 AM
Surely there will be some reason behind it, right ?
Is it like Common Language Specification ?
Mahesh ChandPosted Jul 28, 2011, 1:16 PM
In theory and from language perspective, string is a data type like int or char in C# language.
String is a class that represents the string data type and is a part of .NET Framework.
Vilas GitePosted Jul 28, 2011, 11:10 AM
Refer for more details :
http://msdn.microsoft.com/en-us/library/362314fe(v=vs.71).aspx
Same Thread : http://stackoverflow.com/questions/7074/in-c-what-is-the-difference-between-string-and-string
string Vs String : http://en.csharp-online.net/CSharp_String_Theory—string_versus_String
Guest UserPosted Jul 28, 2011, 9:11 AM
VulpesPosted Jul 28, 2011, 9:11 AM
using System;
This is because the C# keyword 'string' is just an alias for System.String.