本文整理汇总了C#中System.Data.DataTableReader.GetValues方法的典型用法代码示例。如果您正苦于以下问题:C# DataTableReader.GetValues方法的具体用法?C# DataTableReader.GetValues怎么用?C# DataTableReader.GetValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了DataTableReader.GetValues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetValues
private static void TestGetValues(DataTableReader reader)
{
// Given a DataTableReader, use the GetValues
// method to retrieve a full row of data.
// Test the GetValues method, passing in an array large
// enough for all the columns.
Object[] values = new Object[reader.FieldCount];
int fieldCount = reader.GetValues(values);
Console.WriteLine("reader.GetValues retrieved {0} columns.",
fieldCount);
for (int i = 0; i < fieldCount; i++)
Console.WriteLine(values[i]);
Console.WriteLine();
// Now repeat, using an array that may contain a different
// number of columns than the original data. This should work correctly,
// whether the size of the array is larger or smaller than
// the number of columns.
// Attempt to retrieve three columns of data.
values = new Object[3];
fieldCount = reader.GetValues(values);
Console.WriteLine("reader.GetValues retrieved {0} columns.",
fieldCount);
for (int i = 0; i < fieldCount; i++)
Console.WriteLine(values[i]);
}