programming-examples/c-sharp/Strings/C# Program to Split a String Collections into Groups.cs

33 lines
916 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* C# Program to Split a String Collections into Groups
*/
using System;
using System.IO;
using System.Collections;
using System.Linq;
class program
{
static void SendEmail(string email)
{
Console.WriteLine(email);
}
static void Main(string[] args)
{
string[] email = {"One@aaa.com", "Two@aaa.com",
"Three@aaa.com", "Four@aaa.com",
"Five@aaa.com", "Six@aaa.com",
"Seven@aaa.com", "Eight@aaa.com"
};
var Grp = from i in Enumerable.Range(0, email.Length)
group email[i] by i / 3;
foreach (var mail in Grp)
SendEmail(string.Join(";", mail.ToArray()));
Console.ReadLine();
}
}
/*
One@aaa.com;Two@aaa.com;
Three@aaa.com;Four@aaa.com;
Five@aaa.com;Six@aaa.com;
Seven@aaa.com;Eight@aaa.com