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
prefixcharThe introducing character; must be
'#'or';'.textstringThe text of the comment, excluding the prefix character.
lineNumberintThe 1-based source line at which the comment appeared, or
0when the comment was constructed programmatically.
Exceptions
- ArgumentException
prefixis neither'#'nor';'.- ArgumentNullException
textis 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
otherIniCommentAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
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
leftIniCommentThe first comment.
rightIniCommentThe second comment.
Returns
operator !=(IniComment, IniComment)
Determines whether two comments are not equal.
public static bool operator !=(IniComment left, IniComment right)
Parameters
leftIniCommentThe first comment.
rightIniCommentThe second comment.
Returns
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |