I am using Microsoft Visual Studio 2005 with .NET 2.0. I have a comboBox that I use to select a product. After I select a product I am searching for it in a text file – in the end I want to find the line of that product in the file. However with the following code
int lineNo = lineList.IndexOf(lineList.Find(x => x.StartsWith(select)));
the compiler gives the error :
Invalid expression term '>'
Is this a problem with the 2.0 framework version of .NET?
That means you’re using C# 2.
But you’re trying to use a lambda expression (
=>) – a feature introduced in C# 3. It’s not the version of the framework that you’re using – you could write the same code in VS2008 or later, still targeting .NET 2. It’s the version of the language you’re using.You can do something similar in C# 2 with an anonymous method though: