Showing posts from May, 2006

A mighty conversion

I recently ran into a situation where I needed to create an array of integers to a comma-delimited string in .Net. This *should* be easily accomplished by some sort of intrinsic function (like .toString()). But alas, no. So, you can do this (and other sorts of arrays in the following manner:
string strCSV = string.Join(",", Array.ConvertAll<int,string>(SkuList, new Converter<int,string>(Convert.ToString)));
Going the other way you can use something similar to turn the whole thing inside out:
int[] result = Array.ConvertAll<string,int>(strCSV.Split(new char[] { ',' }), new Converter<string,int>(Convert.ToInt32));