Search Results for

    Show / Hide Table of Contents

    Struct ushort

    Represents a 16-bit unsigned integer.

    Inherited Members
    ValueType.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    Namespace: System
    Assembly: mscorlib.dll
    Syntax
    [CLSCompliant(false)]
    public ushort

    Fields

    MaxValue

    Represents the largest possible value of UInt16. This field is constant.

    Declaration
    public const ushort MaxValue = 65535
    Field Value
    Type Description
    ushort
    Remarks

    The value of this constant is 65535; that is, hexadecimal 0xFFFF.

    MinValue

    Represents the smallest possible value of UInt16. This field is constant.

    Declaration
    public const ushort MinValue = 0
    Field Value
    Type Description
    ushort
    Remarks

    The value of this constant is 0.

    Methods

    Parse(string)

    Converts the string representation of a number to its 16-bit unsigned integer equivalent.

    Declaration
    [CLSCompliant(false)]
    public static ushort Parse(string s)
    Parameters
    Type Name Description
    string s

    A string that represents the number to convert.

    Returns
    Type Description
    ushort

    A 16-bit unsigned integer equivalent to the number contained in s.

    Exceptions
    Type Condition
    ArgumentNullException

    s is null.

    ToString()

    Converts the numeric value of this instance to its equivalent string representation.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    The string representation of the value of this instance, which consists of a sequence of digits ranging from 0 to 9, without a sign or leading zeros.

    Overrides
    object.ToString()

    ToString(string)

    Converts the numeric value of this instance to its equivalent string representation using the specified format.

    Declaration
    public string ToString(string format)
    Parameters
    Type Name Description
    string format

    A numeric format string.

    Returns
    Type Description
    string

    The string representation of the value of this instance as specified by format.

    TryParse(string, out ushort)

    Converts the string representation of a number to its 16-bit unsigned integer equivalent. A return value indicates whether the conversion succeeded or failed.

    Declaration
    public static bool TryParse(string s, out ushort result)
    Parameters
    Type Name Description
    string s

    A string that contains a number to convert.

    ushort result

    When this method returns, contains the 16-bit unsigned integer value equivalent to the number contained in s, if the conversion succeeded, or zero if the conversion failed. The conversion fails if the s parameter is null or Empty, is not of the correct format, or represents a number less than MinValue or greater than MaxValue. This parameter is passed uninitialized; any value originally supplied in result will be overwritten.

    Returns
    Type Description
    bool

    true if s was converted successfully; otherwise, false.

    Remarks

    The TryParse(string, out ushort) method differs from the Parse(string) method by returning a bool value that indicates whether the parse operation succeeded instead of returning the parsed short value. It eliminates the need to use exception handling to test for a FormatException in the event that s is invalid and cannot be successfully parsed.

    In This Article
    Back to top Copyright © 2023 nanoFramework Contributors
    Generated by DocFX