Hi,
You already have a string.
StringBuilder
is recommended only in case where you need to append the string. Otherwise it is better to use
string
object directly. Because here you are allocating extra memory to
StringBuilder
object. And on top of that you need a method
ToString()
to convert that to a
string
object. Instead its better to use
string
object directly (it is better for the current scenario).
string s = "val1,val2,val3,val4,val5,val6,val7";
var sSplit = s.Split(',');
txtBox1.Text = sSplit[1];
txtBox2.Text = sSplit[2];
txtBox3.Text = sSplit[4];
txtBox4.Text = sSplit[6];