Adding values to a list based on a string delimiter until the next occurence?

ISeeCode

New member
Joined
Sep 4, 2014
Messages
1
Programming Experience
5-10
Hi,

I have a data string that I put into a list. When I start iterating through the list, I have an if statement that when x.Contains(g), do this. The code that I wrote is..

C#:
string g = "<a class=";
List<string> K = new List<string>();
foreach (var x in myList)
{
 if (x.Contains(g))
 {                    
  K.Add(x);   
 } 
}

The only way I can tell the records apart are from when x.Contains(g), the data looks like this

<a class=........>LastName, FirstName</a>
Address
Phone
City
Etc....
<a class=........>LastName, FirstName</a>

So when x.Contains(g) I want it to keep iterating through and adding each value and when x.Contains(g) again then I want to add the List to a datatable on so forth...

Can someone point me in the right direction if I am doing this write or this is an easier way to do this?


Thanks
 

Latest posts

Back
Top Bottom