String is immutable
String Builder is mutable
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Examples
{
public partial class @string : Form
{
public @string()
{
InitializeComponent();
}
private void @string_Load(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
sb.Append(" World ");
MessageBox.Show(sb.ToString());
sb.Insert(0, " Hello ");
MessageBox.Show(sb.ToString());
sb.Insert(10," how r u ");
MessageBox.Show(sb.ToString());
sb.Remove(5, 2);
MessageBox.Show(sb.ToString());
}
}
}
String Builder is mutable
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Examples
{
public partial class @string : Form
{
public @string()
{
InitializeComponent();
}
private void @string_Load(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
sb.Append(" World ");
MessageBox.Show(sb.ToString());
sb.Insert(0, " Hello ");
MessageBox.Show(sb.ToString());
sb.Insert(10," how r u ");
MessageBox.Show(sb.ToString());
sb.Remove(5, 2);
MessageBox.Show(sb.ToString());
}
}
}
No comments:
Post a Comment