1
Answer

What is wrong in this query

Ask a question
ginni zed

ginni zed

11y
1.1k
1

I have a list AllIDs.
List<IAddress> AllIDs = new List<IAddress>();
I want to to substring operation on a member field AddressId based on a character "_".

I am using below LINQ query but getting compilation error:

AllIDs= AllIDs.Where(s => s.AddressId.Length >= s.AddressId.IndexOf("_")).Select(s => s.AddressId.Substring(s.AddressId.IndexOf("_"))).ToList();


Error:

Cannot implicitly convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.List<MyCompany.Common.Users.IAddress>'

I have a list AllIDs.
List<IAddress> AllIDs = new List<IAddress>();
I want to to substring operation on a member field AddressId based on a character "_".

I am using below LINQ query but getting compilation error:

AllIDs= AllIDs.Where(s => s.AddressId.Length >= s.AddressId.IndexOf("_")).Select(s => s.AddressId.Substring(s.AddressId.IndexOf("_"))).ToList();


Error:

Cannot implicitly convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.List<MyCompany.Common.Users.IAddress>'

 


Answers (1)