mk.helpers
Search Results for

    Show / Hide Table of Contents

    Class RandomHelper

    Provides utility methods for generating random values.

    Inheritance
    object
    RandomHelper
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: mk.helpers
    Assembly: mk.helpers.dll
    Syntax
    public static class RandomHelper

    Methods

    RandomBool()

    Generates a random boolean value (true or false).

    Declaration
    public static bool RandomBool()
    Returns
    Type Description
    bool

    A randomly generated boolean value.

    RandomDate()

    Generates a random DateTime within the default date range.

    Declaration
    public static DateTime RandomDate()
    Returns
    Type Description
    DateTime

    A randomly generated DateTime value.

    RandomDate(DateTime, DateTime)

    Generates a random DateTime within the specified date range.

    Declaration
    public static DateTime RandomDate(DateTime from, DateTime to)
    Parameters
    Type Name Description
    DateTime from

    The minimum date of the range.

    DateTime to

    The maximum date of the range.

    Returns
    Type Description
    DateTime

    A randomly generated DateTime within the specified range.

    RandomDouble()

    Generates a random double between 0.0 and 1.0.

    Declaration
    public static double RandomDouble()
    Returns
    Type Description
    double

    A randomly generated double value.

    RandomInt(int, int)

    Generates a random integer within the specified range.

    Declaration
    public static int RandomInt(int min, int max)
    Parameters
    Type Name Description
    int min

    The minimum value of the random integer.

    int max

    The maximum value of the random integer.

    Returns
    Type Description
    int

    A randomly generated integer.

    RandomNumber(int, int, int)

    Generates a random number within the specified range with the specified number of digits.

    Declaration
    public static double RandomNumber(int min, int max, int digits)
    Parameters
    Type Name Description
    int min

    The minimum value of the random number.

    int max

    The maximum value of the random number.

    int digits

    The number of decimal digits in the generated number.

    Returns
    Type Description
    double

    A randomly generated number with the specified number of digits.

    RandomString(int, bool)

    Generates a random string of the specified size.

    Declaration
    public static string RandomString(int size, bool lowerCase)
    Parameters
    Type Name Description
    int size

    The length of the random string to generate.

    bool lowerCase

    Specify whether the generated string should be in lowercase.

    Returns
    Type Description
    string

    A randomly generated string.

    In this article
    Back to top mk.helpers - MIT License