Try:
for (int i = 0; i < newList.Count - 1; i++)
{
if (newList[i].EndsWith(newList[i + 1]))
return newList[i + 1];
}
"This return only last matching condition.
if we have [0]read ,[1]ad and [2]salt, [3]alt it return only last 'alt' it also return 'ad' and 'alt'"
If that's what you want to do, then you have to explain it to us!
Remember that we can't see your screen, access your HDD, or read your mind.:laugh:
Try this:
List<string>>matches = new List<string>();
for (int i = 0; i < newList.Count - 1; i++)
{
if (newList[i].EndsWith(newList[i + 1]))
matches.Add(newList[i + 1]);
}
The
matches
list contains all the "ad" and "alt" values.