coconet
4/8/2008 2:32:00 PM
I am trying to use LINQ to select some things from a tab-delimited
string. I have a "where" clause but I want to put some if.. logic
inside it. Right now I have this:
MyClassList =
from line in myReader.GetLines()
let lineItems = line.Split( '\t' )
where line.StartsWith( "#" )
select new MyClass
{.....}
But what I want is a "conditional where", so if the line does not
begin with "#" the select new MyClass part runs, but if it does start
with "#" then assign the line to a new string that I will use later.
As you can tell, I am new to LINQ syntax. Is this even possible?
Thanks.