This is a C# Program to split string collections into groups.
This C# Program Splits a String Collections into Groups.
Here the Given String is splited into Groups and displayed.
Here is source code of the C# Program to Split a String Collections into Groups. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * 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 = {"[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]"}; 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(); } }
In this C# program using email[] array variable we are reading the email Ids. The groupby is used to group the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.
The foreach statement is used to iterate through the collection to get the information that you want, but cannot be used to add or remove items from the source collection to avoid unpredictable side effects. Print the given string which is divided into groups.
Sanfoundry Global Education & Learning Series – 1000 C# Programs.
- Get Free Certificate of Merit in C# Programming
- Participate in C# Programming Certification Contest
- Become a Top Ranker in C# Programming
- Take C# Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Practice Computer Science MCQs
- Apply for C# Internship
- Practice MCA MCQs
- Buy C# Books
- Buy Computer Science Books