C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
Java
Learn iOS Programming
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
24
Reply
Is string mutable or immutable?
Guest User
11y
5.5k
0
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
The main difference is system.string is immutable and system.stringbuilder is a mutable. Append keyword is used in string builder but not in system.string. Immutable means once we created we cannot modified. Suppose if we want give new value to old value simply it will discarded the old value and it will create new instance in memory to hold the new value.
Ankur Jain
11y
3
All string objects are immutable in C#.
manikumar maddu
11y
2
strings are always imutable
Abhishek Kumar
9y
1
Immutable
Joe Wilson
9y
1
string iobjects are always immutable
sajidlkhan lodi
10y
1
String objects are NOT ALWAYS immutable. Ignore all posts in this thread that spread this misconception. Below for example I show an example where I take "thequickbrownfox" and change each character in turn into "THEQUICKBROWNFOX" The original string is mutable in this example. String s = "thequickbrownfox"; Console.WriteLine(s); unsafe { fixed (char* ca = s) for (char* c = ca; *c != 0; c++) *c = char.ToUpper(*c); } Console.WriteLine(s);
Michael O'shea
10y
0
Strings are always immutable
Safayat Zisan
10y
0
Immutable string can’t be alter, once we have assign a value to immutable object state can’t be changedWe can assign multiple values to mutable string and object state can be altered.
Kml Surani
10y
0
string objects are always immutable
sajidlkhan lodi
10y
0
string iobjects are always immutable
sajidlkhan lodi
10y
0
string iobjects are always immutable
sajidlkhan lodi
10y
0
string is immutable , can not change value
Ravi Prajapati
10y
0
string is immutable , can not change value
Ravi Prajapati
10y
0
immutable
Gokul Rathod
11y
0
Yes String are immutable.
Dhanik Sahni
11y
0
system.string is immutable
Munesh Sharma
11y
0
Yes String are immutable.
Akhil Garg
11y
0
Immutable,so that they are used for smaller operation
Sunil Gaded
11y
0
All strings are immutable.because if you try to insert a value more than once it will replace previous value.String Builders are mutable.
venky prasad
11y
0
Yes string is a immutable
varunkumar reddy
11y
0
Immutable means string values cannot be changed once they have been created. Any modification to a string value results in a completely new string instance, thus an inefficient use of memory and extraneous garbage collection. The mutable System.Text.StringBuilder class should be used when string values will change.
Najna Abdulla
11y
0
mutable
Payal Sharma
11y
0
String is Immutable, They cannot be altered
shashi p
11y
0
mutable means "changeable" and immutable is acronym of that.strings are immutable.
Guest User
11y
0
What is the use of using statement in C#
What is serialization?
Message