• DnsClient
  • Readme
  • Api Docs
  • MichaCo.net
This site uses "cookies" - small data files stored locally on your computer - to save information about your preferences when using this site. Learn More.

    Show / Hide Table of Contents

    Class DnsString

    The DnsString type is used to normalize and validate domain names and labels.

    Type to normalize domain names used in query and returned results.

    When used as query input, the parsing will check for certain DNS domain name rules.

    The type implicitly converts back to string.

    Inheritance
    Object
    DnsString
    Inherited Members
    Object.Equals(Object, Object)
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Namespace: DnsClient
    Assembly: DnsClient.dll
    Syntax
    public class DnsString

    Fields

    | Improve this Doc View Source

    ACEPrefix

    The ACE prefix indicates that the domain name label contains not normally supported characters and that the label has been endoded.

    Declaration
    public const string ACEPrefix = "xn--"
    Field Value
    Type Description
    String
    | Improve this Doc View Source

    LabelMaxLength

    The maximum lenght in bytes for one label.

    Declaration
    public const int LabelMaxLength = 63
    Field Value
    Type Description
    Int32
    | Improve this Doc View Source

    QueryMaxLength

    The maximum supported total length in bytes for a domain nanme. The calculation of the actual bytes this DnsString consumes includes all bytes used for to encode it as octet string.

    Declaration
    public const int QueryMaxLength = 255
    Field Value
    Type Description
    Int32
    | Improve this Doc View Source

    RootLabel

    The root label ".".

    Declaration
    public static readonly DnsString RootLabel
    Field Value
    Type Description
    DnsString

    Properties

    | Improve this Doc View Source

    Original

    Gets the orginal value.

    Declaration
    public string Original { get; }
    Property Value
    Type Description
    String
    | Improve this Doc View Source

    Value

    Gets the validated and eventually modified value.

    Declaration
    public string Value { get; }
    Property Value
    Type Description
    String

    Methods

    | Improve this Doc View Source

    Equals(Object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj
    Returns
    Type Description
    Boolean
    Overrides
    Object.Equals(Object)
    | Improve this Doc View Source

    FromResponseQueryString(String)

    Transforms names with the ACEPrefix to the unicode variant and adds a trailing '.' at the end if not present. The original value will be kept in this instance in case it is needed.

    Declaration
    public static DnsString FromResponseQueryString(string query)
    Parameters
    Type Name Description
    String query

    The value to check.

    Returns
    Type Description
    DnsString

    The DnsString representation.

    Remarks

    The method does not parse the domain name unless it contains a ACEPrefix.

    | Improve this Doc View Source

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32
    Overrides
    Object.GetHashCode()
    | Improve this Doc View Source

    Parse(String)

    Parses the given query and validates all labels.

    Declaration
    public static DnsString Parse(string query)
    Parameters
    Type Name Description
    String query

    A domain name.

    Returns
    Type Description
    DnsString

    The DnsString representing the given query.

    Remarks

    An empty string will be interpreted as root label.

    Exceptions
    Type Condition
    ArgumentNullException

    If query is null.

    | Improve this Doc View Source

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    String
    Overrides
    Object.ToString()

    Operators

    | Improve this Doc View Source

    Implicit(DnsString to String)

    Performs an implicit conversion from DnsString to String.

    Declaration
    public static implicit operator string (DnsString name)
    Parameters
    Type Name Description
    DnsString name

    The name.

    Returns
    Type Description
    String

    The result of the conversion.

    • Improve this Doc
    • View Source
    © 2025 by Michael Conrad. All rights reserved. - MichaCo.net