How to convert a list into array with Linq

added by jalpesh
2/12/2013 3:39:38 PM

0 Kicks, 91 Views

n this post, I am going to explain how we can convert an generic list to simple int array with Help of Linq. Recently, I was working on an application and there I needed an Int array of for list of ids in generic list. I tried various methods and then with the help of ‘Select’ operator and ToArray method I have easily converted an generic list to the int array. Lets take a simple example. I need a contact id list from a generic list of contacts and following is my contact class. public class Contact { public int ContactId { get; set; } public string Name { get; set; } } Now I have created a new GetContacts methods to create a new Generic List of Contacts.


1 comments

Asava Samuel
2/25/2013 11:22:42 PM
jalpesh It looks like Kellerman Software has a MySQL LINQ Provider: https://www.kellermansoftware.com/p-47-net-data-access-layer.aspx