TextFieldParser.CommentTokens Property

Definition

Defines comment tokens. A comment token is a string that, when placed at the beginning of a line, indicates that the line is a comment and should be ignored by the parser.

C#
public string[]? CommentTokens { get; set; }
C#
public string[] CommentTokens { get; set; }

Property Value

String[]

A string array that contains all of the comment tokens for the TextFieldParser object.

Exceptions

A comment token includes white space.

Examples

This example specifies that for the TextFieldParser, FileReader lines beginning with a single quotation mark (') should be ignored.

VB
FileReader.TextFieldType = 
    Microsoft.VisualBasic.FileIO.FieldType.Delimited
FileReader.CommentTokens = New String() {"'"}

Remarks

This is an advanced member; it does not show in IntelliSense unless you click the All tab.

Zero-length comment tokens are ignored.

Applies to

Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also