Show / Hide Table of Contents

    Class Cat<T, K>

    Here's main class of this Demo.

    You can see mostly type of article within this class and you for more detail, please see the remarks.

    this class is a template class. It has two Generic parameter. they are: T and K.

    The extension method of this class can refer to ICatExtension class

    This is a class talking about CAT.

    NOTE This is a CAT class

    Refer to IAnimal to see other animals.

    Inheritance
    Object
    Cat<T, K>
    Implements
    ICat
    IAnimal
    Inherited Members
    Object.ToString()
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: CatLibrary
    Assembly: CatLibrary.dll
    Syntax
    [Serializable]
    public class Cat<T, K> : ICat, IAnimal where T : class, new()
        where K : struct
    Type Parameters
    Name Description
    T

    This type should be class and can new instance.

    K

    This type is a struct type, class type can't be used for this parameter.

    Remarks

    THIS is remarks overridden in MARKDWON file

    Examples

    Here's example of how to create an instance of this class. As T is limited with class and K is limited with struct.

        var a = new Cat(object, int)();
        int catNumber = new int();
        unsafe
        {
            a.GetFeetLength(catNumber);
        }

    As you see, here we bring in pointer so we need to add unsafe keyword.

    Constructors

    | Improve this Doc View Source

    Cat()

    Default constructor.

    Declaration
    public Cat()
    | Improve this Doc View Source

    Cat(T)

    Constructor with one generic parameter.

    Declaration
    public Cat(T ownType)
    Parameters
    Type Name Description
    T ownType

    This parameter type defined by class.

    | Improve this Doc View Source

    Cat(String, out Int32, String, Boolean)

    It's a complex constructor. The parameter will have some attributes.

    Declaration
    public Cat(string nickName, out int age, string realName, bool isHealthy)
    Parameters
    Type Name Description
    String nickName

    it's string type.

    Int32 age

    It's an out and ref parameter.

    String realName

    It's an out paramter.

    Boolean isHealthy

    It's an in parameter.

    Fields

    | Improve this Doc View Source

    isHealthy

    Field with attribute.

    Declaration
    [ContextStatic]
    [NonSerialized]
    public bool isHealthy
    Field Value
    Type Description
    Boolean

    Properties

    | Improve this Doc View Source

    Age

    Hint cat's age.

    Declaration
    protected int Age { get; set; }
    Property Value
    Type Description
    Int32
    | Improve this Doc View Source

    Item[String]

    This is index property of Cat. You can see that the visibility is different between get and set method.

    Declaration
    public int this[string a] { protected get; set; }
    Parameters
    Type Name Description
    String a

    Cat's name.

    Property Value
    Type Description
    Int32

    Cat's number.

    | Improve this Doc View Source

    Name

    EII property.

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

    Methods

    | Improve this Doc View Source

    Override CalculateFood Name

    It's an overridden summary in markdown format

    This is overriding methods. You can override parameter descriptions for methods, you can even add exceptions to methods. Check the intermediate obj folder to see the data model of the generated method/class. Override Yaml header should follow the data structure.

    Declaration
    public Dictionary<string, List<int>> CalculateFood(DateTime date)
    Parameters
    Type Name Description
    DateTime date

    This is overridden description for a parameter. id must be specified.

    Returns
    Type Description
    Dictionary<String, List<Int32>>

    It's overridden description for return. type must be specified.

    Exceptions
    Type Condition
    System.ArgumentException

    This is an overridden argument exception. you can add additional exception by adding different exception type.

    | Improve this Doc View Source

    Equals(Object)

    Override the method of Object.Equals(object obj).

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj

    Can pass any class type.

    Returns
    Type Description
    Boolean

    The return value tell you whehter the compare operation is successful.

    Overrides
    Object.Equals(Object)
    | Improve this Doc View Source

    GetTailLength(Int32*, Object[])

    It's an unsafe method. As you see, catName is a pointer, so we need to add unsafe keyword.

    Declaration
    public long GetTailLength(int *catName, params object[] parameters)
    Parameters
    Type Name Description
    Int32* catName

    Thie represent for cat name length.

    Object[] parameters

    Optional parameters.

    Returns
    Type Description
    Int64

    Return cat tail's length.

    | Improve this Doc View Source

    Jump(T, K, ref Boolean)

    This method have attribute above it.

    Declaration
    [Conditional("Debug")]
    public void Jump(T ownType, K anotherOwnType, ref bool cheat)
    Parameters
    Type Name Description
    T ownType

    Type come from class define.

    K anotherOwnType

    Type come from class define.

    Boolean cheat

    Hint whether this cat has cheat mode.

    Exceptions
    Type Condition
    System.ArgumentException

    This is an argument exception

    Events

    | Improve this Doc View Source

    ownEat

    Eat event of this cat

    Declaration
    public event EventHandler ownEat
    Event Type
    Type Description
    EventHandler

    Operators

    | Improve this Doc View Source

    Addition(Cat<T, K>, Int32)

    Addition operator of this class.

    Declaration
    public static int operator +(Cat<T, K> lsr, int rsr)
    Parameters
    Type Name Description
    Cat<T, K> lsr

    ...

    Int32 rsr
    Returns
    Type Description
    Int32

    Result with int type.

    | Improve this Doc View Source

    Explicit(Cat<T, K> to Tom)

    Expilicit operator of this class.

    It means this cat can evolve to change to Tom. Tom and Jerry.

    Declaration
    public static explicit operator Tom(Cat<T, K> src)
    Parameters
    Type Name Description
    Cat<T, K> src

    Instance of this class.

    Returns
    Type Description
    Tom

    Advanced class type of cat.

    | Improve this Doc View Source

    Subtraction(Cat<T, K>, Int32)

    Similar with operaotr +, refer to that topic.

    Declaration
    public static int operator -(Cat<T, K> lsr, int rsr)
    Parameters
    Type Name Description
    Cat<T, K> lsr
    Int32 rsr
    Returns
    Type Description
    Int32

    Explicit Interface Implementations

    | Improve this Doc View Source

    IAnimal.Eat()

    EII method.

    Declaration
    void IAnimal.Eat()
    | Improve this Doc View Source

    IAnimal.Eat(String)

    Implementation of Eat(food)

    Declaration
    void IAnimal.Eat(string food)
    Parameters
    Type Name Description
    String food

    Food to eat

    | Improve this Doc View Source

    IAnimal.Eat<Tool>(Tool)

    EII template method.

    Declaration
    void IAnimal.Eat<Tool>(Tool a)
        where Tool : class
    Parameters
    Type Name Description
    Tool a

    Tool name.

    Type Parameters
    Name Description
    Tool

    Tool for eat.

    | Improve this Doc View Source

    IAnimal.Item[Int32]

    EII index.

    Declaration
    string IAnimal.this[int a] { get; }
    Parameters
    Type Name Description
    Int32 a

    Cat's number.

    Returns
    Type Description
    String

    Cat's name.

    | Improve this Doc View Source

    ICat.eat

    EII event.

    Declaration
    event EventHandler ICat.eat
    Returns
    Type Description
    EventHandler

    Implements

    ICat
    IAnimal

    Extension Methods

    ICatExtension.Sleep(ICat, Int64)
    ICatExtension.Play(ICat, String)
    • Improve this Doc
    • View Source
    Back to top Generated by DocFX