Using Linq we can convert list values to string appending with delimiter. Here it is appended with '|' (pipe)
Code snippet:
Example:1
string strData = "World is Mine";
string[] split = strData.Split(' ');
//logic work done on split values.
// .
// .
// .
// .
// .
// .
//
StringBuilder stringBuilder = new StringBuilder();
split.ToList().ForEach(n => stringBuilder.AppendFormat("{0}|", n));
string strOut = stringBuilder.ToString();
Example:2
List<string> itemArray = new List<string>()
{
"CUSTOMERNAME","FIRST CROSS"
};
List<string> masterlst = new List<string>()
{
"CUSTOMERNAME","CUSTOMERNA","B","B1"
};
List<string> ptrn = new List<string>();
itemArray.ForEach(n => ptrn.Add(masterlst.Find(n.Contains)));
No comments:
Post a Comment