difference between string and String in .net

Posted by Shanky11 under ASP.NET on 10/1/2012 | Points: 10 | Views : 922 | Status : [Member] | Replies : 5
string s="shankar";
what is s here?????variable or object




Responses

Posted by: Vasanthmvp on: 10/1/2012 [Member] Starter | Points: 25

Up
0
Down
http://www.dotnetfunda.com/forums/thread4109-difference-between-string-and-string.aspx

Awesome Coding !! :)

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 10/1/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
string :
The string type represents a sequence of zero or more Unicode characters. string is an alias for String in the .NET Framework.
'string' is the intrinsic C# datatype, and is an alias for the system provided type "System.String". The C# specification states that as a matter of style the keyword ('string') is preferred over the full system type name (System.String, or String).
Although string is a reference type, the equality operators (== and !=) are defined to compare the values of string objects, not references. This makes testing for string equality more intuitive. For example:

String :
A String object is called immutable (read-only) because its value cannot be modified once it has been created. Methods that appear to modify a String object actually return a new String object that contains the modification. If it is necessary to modify the actual contents of a string-like object



Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 10/10/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
s is object

Hi.. @Shanky11
if this helps u please Mark As Answer.

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pgayath on: 10/10/2012 [Member] Starter | Points: 25

Up
0
Down
Shankar,

The alias name for System.String is string. There is no difference technically..

string is recommended for objects and String is recommended for classes. In reflection you should use String.

Thanks and Regards,
Gayathri P

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pgayath on: 10/10/2012 [Member] Starter | Points: 25

Up
0
Down
s is object

Thanks and Regards,
Gayathri P

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response