@ankit goel , Welcome to Microsoft Q&A, you could try to define Dictionary<string, List<string>>
to get the wanted data.
Here is a code example you could refer to.
Dictionary<string, List<string>> dic = new Dictionary<string, List<string>>();
for (int i = 0; i < list.Count; i++)
{
string key = list[i];
List<string> l = new List<string>();
foreach (var item in listnew)
{
if (item[0].ToString().Contains(key))
{
l.Add(item[0].ToString().Replace(key, ""));
}
}
dic.Add(key, l);
}
Result:
Best Regards,
Jack
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.