LIST<CLASS> TO LIST<STRING>

Manoj Bhatt

Total Post:154

Points:1086
Posted by  Manoj Bhatt
C# 
C#
 1514  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. Pravesh Singh

    Post:412

    Points:2888
    Re: List<Class> to List<string>

    Hi Manoj,


    Try this:

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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!