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

i

Glossary Item Box

Returns typeof(String)

Syntax

Visual Basic (Declaration) 
Public Function GetFieldType( _
   ByVal i As Integer _
) As Type
C# 
public Type GetFieldType( 
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C#Copy Code
using (CsvReader r = new CsvReader(new StringReader(CSV_DOC1)))
{
    Assert.AreEqual(3, r.FieldCount);
    for (int i = 0; i < r.FieldCount; i++)
    {
        Assert.AreEqual(typeof(String), r.GetFieldType(i));
        Assert.AreEqual(typeof(String).Name, ((IDataReader)r).GetDataTypeName(i));
        Assert.AreEqual("f" + (i + 1).ToString(), r.GetName(i).ToString());
        Assert.AreEqual(i, r.GetOrdinal("f" + (i + 1).ToString()));
    }

    while (r.Read())
    { }

    Assert.IsFalse(r.IsClosed);
    Assert.IsFalse(((IDataReader)r).NextResult());
    Assert.IsTrue(r.IsClosed);
}
VB.NETCopy Code
Using r As New CsvReader(New StringReader(CSV_DOC1))
    Assert.AreEqual(3, r.FieldCount)
    Dim i As Integer = 0
    While i < r.FieldCount
        Assert.AreEqual(GetType([String]), r.GetFieldType(i))
        Assert.AreEqual(GetType([String]).Name, (DirectCast(r, IDataReader)).GetDataTypeName(i))
        Assert.AreEqual("f" + (i + 1).ToString(), r.GetName(i).ToString())
        Assert.AreEqual(i, r.GetOrdinal("f" + (i + 1).ToString()))
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    While r.Read()
    End While

    Assert.IsFalse(r.IsClosed)
    Assert.IsFalse((DirectCast(r, IDataReader)).NextResult())
    Assert.IsTrue(r.IsClosed)
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