mk.helpers
Search Results for

    Show / Hide Table of Contents

    Class ObjectExtensions

    Provides extension methods for object manipulation.

    Inheritance
    object
    ObjectExtensions
    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 ObjectExtensions

    Methods

    AsDictionary(object)

    Converts an object's public properties to a dictionary.

    Declaration
    public static IDictionary<string, object> AsDictionary(this object obj)
    Parameters
    Type Name Description
    object obj

    The object to convert.

    Returns
    Type Description
    IDictionary<string, object>

    A dictionary containing the object's property names and values.

    IsDefault<T>(T)

    Determines whether the specified object is the default value for its type.

    Declaration
    public static bool IsDefault<T>(this T obj)
    Parameters
    Type Name Description
    T obj

    The object to check.

    Returns
    Type Description
    bool

    true if the object is the default value; otherwise, false.

    Type Parameters
    Name Description
    T

    The type of the object.

    IsIn<T>(T, params T[])

    Determines whether the specified object is contained in the given set of values.

    Declaration
    public static bool IsIn<T>(this T obj, params T[] values)
    Parameters
    Type Name Description
    T obj

    The object to check.

    T[] values

    The set of values to check against.

    Returns
    Type Description
    bool

    true if the object is in the set of values; otherwise, false.

    Type Parameters
    Name Description
    T

    The type of the object.

    ToExpandoObject(object)

    Converts an object into an ExpandoObject, copying all its properties. Complex types and collections are recursively converted.

    Declaration
    public static ExpandoObject ToExpandoObject(this object obj)
    Parameters
    Type Name Description
    object obj

    The object to convert to ExpandoObject.

    Returns
    Type Description
    ExpandoObject

    An ExpandoObject representing the original object's properties. Returns null if the input object is null.

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