Table of Contents

IniComment Struct

Definition

Namespace
Bodu.Text.Configuration
Assembly
Bodu.Text.Configuration.dll
Package
Bodu.Text.Configuration 1.0.0
Source
IniComment.cs

Represents a single comment line preserved as trivia within an IniDocument.

public readonly struct IniComment : IEquatable<IniComment>
Implements
Inherited Members
Extension Methods

Remarks

Each IniComment records the prefix character that introduced the line (either '#' or ';'), the trimmed text, and the 1-based source line at which it appeared.

Pending comments are attached to the next entry or section in source order: comments authored before a property line appear in LeadingComments; comments authored before a section header appear in LeadingComments.

Constructors

IniComment(char, string, int)

Initializes a new instance of the IniComment struct.

public IniComment(char prefix, string text, int lineNumber = 0)

Parameters

prefix char

The introducing character; must be '#' or ';'.

text string

The text of the comment, excluding the prefix character.

lineNumber int

The 1-based source line at which the comment appeared, or 0 when the comment was constructed programmatically.

Exceptions

ArgumentException

prefix is neither '#' nor ';'.

ArgumentNullException

text is null.

Properties

LineNumber

Gets the 1-based source line at which the comment appeared, or 0 when programmatically constructed.

public int LineNumber { get; }

Property Value

int

A non-negative line number.

Prefix

Gets the prefix character that introduced this comment.

public char Prefix { get; }

Property Value

char

Either '#' or ';'.

Text

Gets the comment text, excluding the prefix character.

public string Text { get; }

Property Value

string

A non-null string.

Methods

Equals(IniComment)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(IniComment other)

Parameters

other IniComment

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Operators

operator ==(IniComment, IniComment)

Determines whether two comments are equal.

public static bool operator ==(IniComment left, IniComment right)

Parameters

left IniComment

The first comment.

right IniComment

The second comment.

Returns

bool

true when the comments are equal.

operator !=(IniComment, IniComment)

Determines whether two comments are not equal.

public static bool operator !=(IniComment left, IniComment right)

Parameters

left IniComment

The first comment.

right IniComment

The second comment.

Returns

bool

true when the comments differ.

Applies to

ProductVersions
.NET8, 10