Enginerds

11/01/2009

String vs. System.String

Filed under: Uncategorized — Mart Leet @ 11:10

Lately I was asked about difference with string and System.String and the right answer is that there’s no differences at all:

What is more efficient in respect of memory usage and performance: The use of string or the use of System.String?

The correct answer is It doesn’t matter which one you take, they perform equally. string is a synonym for System.String. Therefore it does not matter if you take string or System.String.

Source.Equals(“CShapDotNETSecrets”);

Little more about string:

A string is a sequential collection of Unicode characters that is used to represent text. A String object is a sequential collection of System..::.Char objects that represent a string. The value of the String object is the content of the sequential collection, and that value is immutable.

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, use the System.Text..::.StringBuilder class.

Source.Equals(“MSDN”);

Advertisement

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.