List<Class> to List<string>

Total Post:154

Points:1086

C# 
C#
 2206  View(s)
Ratings:
Rate this:
public class emp
{
    public int id {get; set; }
    public string name{ get; set; }
}
public class employee
{
    public List<emp> Result { get; set; }
}

I want to convert above class

List<employee> e=new List<employee>();

to

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

Can anyone guide me? Thanks in advance.

  1. Re: List<Class> to List<string>

    Hi Manoj,


    Try this:

    List<String> onj = e.Select(employee => employee.Name).ToList();

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.