This is a quite common situation and usually we have 2 approaches: 1 create an array of string with the first element empty so we can replace directly
String[] months = { "", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; //first empty so we can replace directly
for(int i =1;i <=12;i++)
{
//Do the magic
xval.Add(months[i] );
}
or we could create the same array without the empty element and replace the index minus one (which seems less readable to me)
Since it is a quite common use case, are there any better options (more readable maybe) to replace the month number to month name? (i.e. 1/12/1983 to 1/Dec/1983 and so on)