c# - Using Linq to find a value in comma separated value in a List -


I have a file class and each file has a list of rows. Each line contains a code that has different values ​​than commas. I need to know that there is a special value present in different data from commas.

  public class file {public list & lt; Line & gt; Rows {get; Set; }} Public class line {public string code {get; Set; }}  

Here the code has comma separated values ​​such as abc, def, ghi || Xyz, ghj, klm

I have to select the line which is in the form of code outside the list of rows in the form of ABC file using Linq in I

If you just want a boolean:

  var ispresent = listOfRows.Any (r = & gt; R.Code.Split (",") Anyone (S => (--- your status ---));  

If you match your position Rows with code property value:

  var rows = list prefix where (r = & gt; r.Code.Split ","). Anyone (s = & gt; (--- your status ---));  

If you want to value only code properties:

  Var value = listOfRows.Select (r = & gt; r.Code.Split (",")) where (S => (--- your position ---);  

Comments