.NET has built-in functionality to convert one collection or array of one type (e.g. List<typename>) to another collection or array of another type. You don't need a for loop to do this at all. Here's how:
(from http://gsharper.blogspot.com/2007/04/convert-integer-array-to-string-array.html)
private void TestMethod(int[] intArray)
{
string[] stringArray = Array.ConvertAll
}
private string ConvertIntToString(int intParameter)
{
return intParameter.ToString();
}
No comments:
Post a Comment