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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sam HobbsRank #107 · 20.5K reputationPosted Jul 28, 2011, 8:03 AM EDT
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.
VulpesRank #55 · 29.2K reputationPosted Jul 28, 2011, 5:11 AM EDT
using System;
This is because the C# keyword 'string' is just an alias for System.String.
Guest UserRank #1,422 · 1.2K reputationPosted Jul 28, 2011, 5:11 AM EDT
Vilas GiteRank #951 · 2.1K reputationPosted Jul 28, 2011, 7:10 AM EDT
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
Mahesh ChandRank #1 · 393.3K reputationPosted Jul 28, 2011, 9:16 AM EDT
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.
Manikavelu VelayuthamRank #413 · 6K reputationPosted Jul 29, 2011, 1:05 AM EDT
Surely there will be some reason behind it, right ?
Is it like Common Language Specification ?
VulpesRank #55 · 29.2K reputationPosted Jul 29, 2011, 1:26 AM EDT
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 VelayuthamRank #413 · 6K reputationPosted Jul 29, 2011, 1:38 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jul 29, 2011, 2:00 AM EDT
Manikavelu VelayuthamRank #413 · 6K reputationPosted Jul 29, 2011, 3:27 AM EDT