J.Doe
J.Doe

Reputation: 31

What type of columns would be created executing this code?

I have created a function that reads a Tab Delimited text file and create a data table as per it's header arrangement.

below is my code:

Private Function MakeDataTable(ByRef XSplitLine) As DataTable
    Dim AMZTable As New DataTable
    Dim i = 0
    For Each item In XSplitLine
        AMZTable.Columns.Add(XSplitLine(i).ToString)
        i += 1
    Next

    Return AMZTable
End Function

XSplitLine is an array that holds header Name(First Line in that text file) from a text file. As you can see I have not mentioned any data types while creating columns but still it executes without any error.

My question is what type of Value can be stored in these columns as I haven't mentioned it in the code?

Upvotes: 0

Views: 96

Answers (1)

MatSnow
MatSnow

Reputation: 7517

The datatype of the columns will be of type String.

As can be seen in https://referencesource.microsoft.com, the used overload of DataColumnCollection.Add calls the constructor of DataColumn which accepts a string as argument.
This in turn calls the constructor which accepts four arguments and sets the second argument (datatype) to typeof(string).

Upvotes: 0

Related Questions