This is a discussion on Converting a generics List<T> to string[] within the C# Programming forums, part of the Software Development category; Is there any easy way to convert a List<T>containing string data to string[]? I'm trying ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Is there any easy way to convert a List<T>containing string data to string[]? I'm trying to convert some sample code from using Enums.
__________________ The OXYGEN Delivers edgy, intelligent Technology to all... |
| Sponsored Links |
| |||
| I am pretty sure you can do the following string[] bar = (string[])list1.ToArray (typeof(string)); Where list1 is your List<string> I hope that helps,
__________________ S.Balasubramanian Nothing is impossible |
| |||
| hi, can you try something like following List<string> li =new List<string>(); li.Add("list1"); li.Add("list1"); li.Add("list2"); li.Add("list3"); string[] si = li.ToArray(); Response.Write(si[0]);
__________________ S.Balasubramanian Nothing is impossible |
| |||
| I have a list of something other than strings, then how to convert it into string array? Can you give me any idea?
__________________ The OXYGEN Delivers edgy, intelligent Technology to all... |
| |||
| Hi, Use this to retrieve other than string. List myList = new List(); // populate myList; string[] myStringArray = myList.ConvertAll<string>(delegate(int ii) { return ii.ToString(); }).ToArray();
__________________ S.Balasubramanian Nothing is impossible |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Converting image from one format to another in C# | Sathish Kumar | C# Programming | 24 | 06-04-2008 02:06 AM |
| Compare a string with String Array. | oxygen | C# Programming | 5 | 12-28-2007 11:18 PM |
| What is diffrenece between string.compare and string.compareordinal | shaalini | ASP and ASP.NET Programming | 3 | 12-28-2007 10:46 PM |
| Converting Nikon camera RAW images to JPEG,TIFF files using Adobe dll in C#.NET | oxygen | C# Programming | 5 | 08-16-2007 03:26 AM |
| How to split a string by using a string usually in the c# dotnet... | Archer | C# Programming | 1 | 07-25-2007 03:26 AM |