CSharpTest.Net
FieldCount Property
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : FieldCount Property

Glossary Item Box

Returns the number of fields defined in this record

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property FieldCount As Integer
C# 
public int FieldCount {get;}

Example

Library/Library.Test/TestCsvReader.cs

C#Copy Code
using (TempFile temp = new TempFile())
{
    File.WriteAllText(temp.TempPath, CSV_DOC1);
    using (CsvReader r = new CsvReader(temp.TempPath))
    {
        Assert.AreEqual(3, r.FieldCount);
        int row = 0;
        while (r.Read())
        {
            for (int col = 0; col < 3; col++)
            {
                Assert.AreEqual(CSV_DOC1_VAL[row, col], r.GetString(col));
            }

            row++;
        }

        Assert.AreEqual(5, row);
        Assert.AreEqual(5, r.RecordsAffected);
    }
}
VB.NETCopy Code
Using temp As New TempFile()
    File.WriteAllText(temp.TempPath, CSV_DOC1)
    Using r As New CsvReader(temp.TempPath)
        Assert.AreEqual(3, r.FieldCount)
        Dim row As Integer = 0
        While r.Read()
            Dim col As Integer = 0
            While col < 3
                Assert.AreEqual(CSV_DOC1_VAL(row, col), r.GetString(col))
                System.Math.Max(System.Threading.Interlocked.Increment(col),col - 1)
            End While

            System.Math.Max(System.Threading.Interlocked.Increment(row),row - 1)
        End While

        Assert.AreEqual(5, row)
        Assert.AreEqual(5, r.RecordsAffected)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys