Cat<T,K> Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released.
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
[System.Serializable]
public class Cat<T,K> : CatLibrary.ICat where T : class, new() where K : struct
Type Parameters
- 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.
- Inheritance
-
Cat<T,K>
- Attributes
- Implements
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.
Remarks
Here's all the content you can see in this class.
Constructors
Cat<T,K>() |
Default constructor. |
Cat<T,K>(String, Int32, String, Boolean) |
It's a complex constructor. The parameter will have some attributes. |
Cat<T,K>(T) |
Constructor with one generic parameter. |
Fields
isHealthy |
Field with attribute. |
Properties
Age |
Hint cat's age. |
Item[String] |
This is index property of Cat. You can see that the visibility is different between |
Name |
EII property. |
Methods
CalculateFood(DateTime) |
It's a method with complex return type. |
Equals(Object) |
Override the method of |
GetTailLength(Int32*, Object[]) |
It's an |
Jump(T, K, Boolean) |
This method have attribute above it. |
Operators
Addition(Cat<T,K>, Int32) |
Addition operator of this class. |
Explicit(Cat<T,K> to Tom) |
Expilicit operator of this class. It means this cat can evolve to change to Tom. Tom and Jerry. |
Subtraction(Cat<T,K>, Int32) |
Similar with operaotr +, refer to that topic. |
Events
ownEat |
Eat event of this cat |
Explicit Interface Implementations
IAnimal.Eat() |
EII method. |
IAnimal.Eat(String) |
Implementation of Eat(food) |
IAnimal.Eat<Tool>(Tool) |
EII template method. |
IAnimal.Item[Int32] |
EII index. |
ICat.eat |
Extension Methods
Play(ICat, String) |
Extension method to let cat play |
Sleep(ICat, Int64) |
Extension method hint that how long the cat can sleep. |