string str ="101,102,103,105,201,250,2564,245564,212,2415,2102,5645,656,444,555";
string[] arl = str.Split(',');
if (arl.Length > 5)
{
string[] strResult;
int totCount = arl.Length / 5;
int totReminder = arl.Length % 5;
if (totReminder > 0)
{
strResult = new string[totCount + 1];
}
else
{
strResult = new string[totCount];
}
for (int i = 0; i < totCount; i++)
{
strResult[i] = arl[i].ToString() + "," + arl[i + 1].ToString() + "," + arl[i + 2].ToString() + "," + arl[i + 3].ToString() + "," + arl[i + 4].ToString();
}
if (totReminder > 0)
{
for (int i = 5 * totCount; i < arl.Count(); i++)
{
strResult[strResult.Length - 1] = strResult[strResult.Length - 1] + arl[i];
if (i < (arl.Count() - 1))
{
strResult[strResult.Length - 1] = strResult[strResult.Length - 1] + ",";
}
}
}
}
else
{
}