using System.Xml.Serialization;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Data.DataSetExtensions;
public static void Main()
DataTable dt = new DataTable();
dt.Columns.Add("id", typeof(int));
dt.Columns.Add("name", typeof(string));
dt.Rows.Add(new object[] {1, "A"});
dt.Rows.Add(new object[] {2, "b"});
dt.Rows.Add(new object[] {3, "s"});
dt.Rows.Add(new object[] {4, "c"});
dt.Rows.Add(new object[] {5, "d"});
dt.Rows.Add(new object[] {6, "f"});
var newdt = dt.AsEnumerable().OrderRandomly().CopyToDataTable();
foreach(DataRow row in newdt.Rows)
Console.WriteLine(string.Join(",", row.ItemArray));
public static class Extension
private static Random random = new Random();
public static IEnumerable<T> OrderRandomly<T>(this IEnumerable<T> items)
List<T> randomly = new List<T>(items);
while (randomly.Count > 0)
Int32 index = random.Next(randomly.Count);
yield return randomly[index];
randomly.RemoveAt(index);