TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Close
AUTHOR
share
facebook
twitter
LinkedIn
GitHub
Karthikeyan
India
Member since Mar 22 2007
1399
rank
6.6
k
read
342
Reputation
Bronze
Member
0
Likes
Bio
class Student
{
public int Id;
public string Name;
}
static DataTable GetDataTable(Student[] students)
{
DataTable table = new DataTable();
table.Columns.Add("Id", typeof(Int32));
table.Columns.Add("Name", typeof(string));
foreach (Student student in students)
{
table.Rows.Add(student.Id, student.Name);
}
return (table);
}
The OutputDataTableHeader Method
static void OutputDataTableHeader(DataTable dt, int columnWidth)
{
string format = string.Format("{0}0,-{1}{2}", "{", columnWidth, "}");
// Display the column headings.
foreach(DataColumn column in dt.Columns)
{
Console.Write(format, column.ColumnName);
}
Console.WriteLine();
foreach(DataColumn column in dt.Columns)
{
for(int i = 0; i < columnWidth; i++)
{
Console.Write("=");
}
}
Console.WriteLine();
}
---------------------
Distinct
The Distinct Prototype
public static IEnumerable<T> Distinct<T> (
this IEnumerable<T> source,
IEqualityComparer<T> comparer);
Student[] students = {
new Student { Id = 1, Name = "Joe Rattz" },
new Student { Id = 6, Name = "Ulyses Hutchens" },
new Student { Id = 19, Name = "Bob Tanko" },
new Student { Id = 45, Name = "Erin Doutensal" },
new Student { Id = 1, Name = "Joe Rattz" },
new Student { Id = 12, Name = "Bob Mapplethorpe" },
new Student { Id = 17, Name = "Anthony Adams" },
new Student { Id = 32, Name = "Dignan Stephens" }<
https://www.c-sharpcorner.com/members/karthikeyan-thangaraju
Recognitions & Awards
Member of Month
CSharp MVP
chapter Lead
Vip
speaker
Recent Posts
   
Most popular
No contribution found in last 2 years label>
contributions
Articles
[0]
Featured
[0]
Forums
[0]
videos
[0]
blogs
[1]
EBooks
[0]
Ideas
[0]
interview questions
[0]