AUTHOR
    share
  • India
  • Member since Mar 22 2007

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" }<

Recent Posts     Most popular

    No contribution found in last 2 years