Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 2930 |  Welcome, Guest!   Register  Login
 Home > Forums > ASP.NET > What is the difference between the string and String ...
Balajirnaukri@Gmail.Com

What is the difference between the string and String

Replies: 8 | Posted by: Balajirnaukri@Gmail.Com on 4/30/2012 | Category: ASP.NET Forums | Views: 391 | Status: [Member] | Points: 10  


I have seen two string datatype one with lower case and other with upper case.what is the exact difference between them?????????

Thanks and Regards
Balaji.R
ASP.NET Devloper
Solve-IT corp


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Sakthi.Singaravel
Sakthi.Singaravel  
Posted on: 4/30/2012 11:11:27 AM
Level: Silver | Status: [Member] | Points: 25


use of string to declare types - variables, properties, return values and parameters. This is consistent with the use of other system types - int, bool, var etc (although Int32 and Boolean are also correct).

use of String when using the static methods on the String class, like String.Split() or String.IsNullOrEmpty().


Regards,
Singaravel M

Balajirnaukri@Gmail.Com, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Funda
Funda  
Posted on: 4/30/2012 11:40:32 AM
Level: Starter | Status: [Member] | Points: 25

Nothing really,
In C# the type keywords actually are equivalent for the types.
Example :
int = System.Int32
short = System.Int16
string = System.String.
They have the keywords because they are easier to remember and programmers coming from other languages would also be familiar with these types.

Answer for your question
string is an alias for String in the .NET Framework.
Strings are immutable--the contents of a string object cannot be changed after the object is created.

Balajirnaukri@Gmail.Com, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Funda
Funda  
Posted on: 4/30/2012 11:45:01 AM
Level: Starter | Status: [Member] | Points: 25

Hi,
String.Split() can also use in string.Also nothing cause when you use static methods with string /String.

Balajirnaukri@Gmail.Com, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Akiii
Akiii  
Posted on: 4/30/2012 9:38:31 PM
Level: Bronze | Status: [Member] | Points: 25

@Vivian .......good answer


Thanks and Regards
Akiii

Balajirnaukri@Gmail.Com, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Gaur1982
Gaur1982  
Posted on: 5/1/2012 2:15:00 AM
Level: Starter | Status: [Member] | Points: 25

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

Difference between string & String :
the string is usually used for declaration while String is used for accessing static string methods
we can use 'string' do declare fields, properties etc that use the predefined type 'string', since the C# specification tells me this is good style.
we can use 'String' to use system-defined methods, such as String.Compare etc. They are originally defined on 'System.String', not 'string'. 'string' is just an alias in this case.
we can also use 'String' or 'System.Int32' when communicating with other system, especially if they are CLR-compliant. I.e. - if I get data from elsewhere, I'd deserialize it into a System.Int32 rather than an 'int', if the origin by definition was something else than a C# system.

Gaurav Agrawal
http://planetofcoders.com/

Balajirnaukri@Gmail.Com, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Funda
Funda  
Posted on: 5/8/2012 2:33:10 AM
Level: Starter | Status: [Member] | Points: 25

:-)

Balajirnaukri@Gmail.Com, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Funda
Funda  
Posted on: 5/11/2012 5:21:21 AM
Level: Starter | Status: [Member] | Points: 25

Hi, @Akiii
Please Mark As Answer.If it helps you.

Regards
Funda...


Balajirnaukri@Gmail.Com, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Akiii
Akiii  
Posted on: 5/11/2012 5:25:07 AM
Level: Bronze | Status: [Member] | Points: 25

hello funda ..this question is asked by Balaji......

Akiii

Balajirnaukri@Gmail.Com, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/19/2013 11:45:06 PM