I'm having some issues with a bit of LINQ syntax and I believe I'm missing something very simple here.
I've got a basic class defined as:
public class ParseData
{
public int Offset { get; set; }
public int Length { get; set; }
public string AssociatedCode { get; set; }
}
I have a collection of these class items that will be processed:
public ObservableCollection<ParseData> OffsetList { get; set; }
I have a method that queries this collection to see if there are any entries that match a particular criteria and based on whether or not any do, will process the items involved differently.
Here's the syntax I'm using (LINQ syntax first in while loop):
private void ParseText()
{
//Prep code for while loop
while (currentSpacePosition != -1)
{
var possibleOffset = OffsetList.Where(offset => offset.Offset.Equals(currentCursorPosition)).ToList<ParseData>();
nextCursorPosition = currentSpacePosition + 1;
currentTextBlock = Text.Substring(currentCursorPosition,(currentSpacePosition - currentCursorPosition) + 1);
if (possibleOffset.Count != 0)
{
//Process one way;
AddHyperlinkButton(currentTextBlock);
}
else
{
//Process another way.
AddTextBlock(currentTextBlock);
}
currentCursorPosition = nextCursorPosition;
currentSpacePosition = Text.IndexOf(' ', currentCursorPosition);
}
//More processing
}
What am I missing here? The poosibleOffset variable keeps returning an empty list, though if I step through the code, there is an an item in the OffsetList that contains an offset prerty that will meet my criteria for selection, which suggest that my syntax isn't correct when trying to check values.
If you need more code or information about the process, I'll be happy to provide it.
Thanks in advance.
Cheers,
Steve