C# Concatenate strings using backslash
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?开发者_JAVA百科
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);
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);
Try this,
string str = string.Format(@"{0}\{1}\{2}\{3}", a, b, c, d);
精彩评论