Q:

C# - Linq to SQL , type conversion error

new to LINQ & would like to know why the error & best way to resolve.
I am getting, 'Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'System.Collections.Generic.List'. An explicit conversion exists (are you missing a cast?)' error
List<string> names = new List<string>();
names.Add("audi a2");
names.Add("audi a4");

List<string> result1 = new List<string>();

result1=(from name in names
         where name.Contains("a2")
         select name);

A:

The result of the from is an IEnumerable, you need to create a list to hold it.
result1=(from name in names
                    where name.Contains("a2")
                    select name).ToList();

so you can simply:
List<string> result1 = (from name in names
                                 where name.Contains("a2")
                                 select name).ToList();

A:

Throw on .ToList() at the end of your Linq query.
result1=(from name in names
     where name.Contains("a2")
     select name).ToList();

