@Binumon George , I recommend that you use select new method to get many columns from the result.
Here is a code example you could refer to.
class Program
{
static void Main(string[] args)
{
List<Person> list = new List<Person>();
list.Add(new Person { Name="test1",Age=22 });
list.Add(new Person { Name="test6", Age=20 });
list.Add(new Person { Name="test3", Age=21 });
list.Add(new Person { Name="test9", Age=22 });
var result = from t in list
orderby t.Name
select new
{
t.Name,
t.Age
};
foreach (var item in result)
{
Console.WriteLine(item.Age);
Console.WriteLine(item.Name);
}
}
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
}
Result:
If I have some misunderstanding, Please feel free to let me know.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.