string s1Temp ="";
string strtemp= "resourceID like'"'+s1Temp+'"' or"
string[] strNames = { "Joe", "Mary", "Bill", "Fred" };
//Iterate thro开发者_JAVA技巧ugh the items of array strNames
for (int i = 0; i < strNames.Length; i++)
{
string s2 = strNames[i];
s1Temp=s2
}
}
how to add the strings strtemp as loop itetares now i need to get the ouput like this iterate through all the strings
resourceID like'"'+Joe+'"' or resourceID like'"'+Mary+'"' or resourceID like'"'+Bill+'"' or resourceID like'"'+Fred+'"' or
thank you
string[] strNames = { "Joe", "Mary", "Bill", "Fred" };
string strtemp= "resourceID like '" + String.Join("' or resourceId like '", strNames) + "'";
String.Join
takes a delimiter and a string array, and inserts the delimiter between each item in the array. This would give you Joe','Mary','Bill','Fred
. The last line adds the initial and the final single quotes.
string[] strNames = { "Joe", "Mary", "Bill", "Fred" };
string s1Temp = String.Join("','", strNames);
s1Temp = String.Format("'{0}'", s1Temp);
精彩评论