0
Bu, bir tablo oluşturduğum koddur. Bu kod tüm satırları döndürür ama ürünün fiyat büyüktür 6.Veri kümesinden belirli satırlar nasıl okunur
class Program
{
static void Main(string[] args)
{
DataTable MyTable = GetTable(); // Get the data table.
foreach (DataRow row in MyTable.Rows) // Loop over the rows.
{
Console.WriteLine("--- Row ---");
foreach (var item in row.ItemArray) // Loop over the items.
{
Console.Write("Item: ");
Console.WriteLine(item);
}
}
Console.Read(); // Pause.
}
static DataTable GetTable()
{
DataTable table = new DataTable();
table.Columns.Add("Price", typeof(int));
table.Columns.Add("Name", typeof(string));
table.Rows.Add(15, "Bag");
table.Rows.Add(4, "Candies");
table.Rows.Add(2, "Cookies");
table.Rows.Add(20, "Books");
table.Rows.Add(8, "Chocolates");
return table;
}
}
}
Zaten denedim ama çalışmıyor –
Denediğinizde ne olur? Bir istisna mı atıyor yoksa ne? –
basitçe tüm çıktılar özel satırları göstermiyor –