- If the type will perform better as a value type rather than reference, use a structure instead of class.
- Instance size less than 16bytes
- Represents a single value
- Will not be changed after creation
- Will not be cast to a Reference type
Advantages of using Generics:
- Processing is fast as boxing and unboxing are not required
- Catch errors at compile time by ensuring typesafety
- You can use constraints on the types: Interface,Base Class,Constructor,Reference or ValueType
IConvertible: Converts an object to CLR datatypes
ICloneable: defines the Clone method that you can implement to do a deep cloning of an object and it's references to other objects
IFormattable: defines the ToString method that you can implement to format the value of the current instance by using the specified format.
IDisposable: defines the dispose method that you can implement to release the resources with the help of a supporting custom-defined ReleaseResource method and remove the current object from the finalization queue. This relieves the garbage collector from calling the finalizer of an object after the object is disposed
New in 2.0
- Nullable
- Operator
- Generic types .eg.EventHandler
IEquatable: applicable to Generic class used Equal method
TypeForwarding
- Conversion operator ( Vb.Net:Widening,Narrowing C#:implicit,explicit)
No comments:
Post a Comment