Reputation: 11
I want to combine four variables like this :
string a,b,c,d;
string Qno = "a\b\c\d";
How to do for above result?
Upvotes: 1
Views: 4071
Reputation: 94653
Try this,
string str = string.Format(@"{0}\{1}\{2}\{3}", a, b, c, d);
Upvotes: 3
Reputation: 292725
Are you trying to build a file path? If you do, check out the Path.Combine method:
string path = Path.Combine(a, b, c, d);
Upvotes: 4
Reputation: 35803
string Qno = string.Format("{0}\\{1}\\{2}\\{3}", a,b,c,d);
or if you have the strings in an array you can use string.Join:
string Qno = string.Join("\\", myArray);
Upvotes: 7