Update for 22-02-22 15:30
This commit is contained in:
parent
a8bde7a353
commit
33a3280b31
@ -104,7 +104,7 @@ declare a class as `abstract`.
|
|||||||
|
|
||||||
To override a class add the modifier `override`.
|
To override a class add the modifier `override`.
|
||||||
|
|
||||||
== Interfaces ==
|
== [[interface]] ==
|
||||||
|
|
||||||
An interface is a fully abstract class that can be inherited by other classes.
|
An interface is a fully abstract class that can be inherited by other classes.
|
||||||
It provides some set functions to be implimented by the child class.
|
It provides some set functions to be implimented by the child class.
|
||||||
@ -127,6 +127,8 @@ It provides some set functions to be implimented by the child class.
|
|||||||
}
|
}
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
|
See [[interface]]
|
||||||
|
|
||||||
== Examples ==
|
== Examples ==
|
||||||
|
|
||||||
=== Hello World ===
|
=== Hello World ===
|
||||||
|
37
tech/interface.wiki
Normal file
37
tech/interface.wiki
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
= Interface =
|
||||||
|
|
||||||
|
An interface is a paradigm where an abstract class defines some set of abstract
|
||||||
|
functions that a class inheriting it can define. This is a core concept in C#.
|
||||||
|
|
||||||
|
In C# an interface can be declared with the `interface` keyword in its
|
||||||
|
declaration. However, there are several built in interfaces that are very
|
||||||
|
useful.
|
||||||
|
|
||||||
|
== Built in C# interfaces ==
|
||||||
|
|
||||||
|
=== System.IComparable ===
|
||||||
|
|
||||||
|
Something that wants to be IComparable must impliment
|
||||||
|
`public int CompareTo(object obj)`. This must return,
|
||||||
|
* Less than zero if the current instance preceds the object specified in sort
|
||||||
|
order
|
||||||
|
* Zero if the current instance is in the same position in the sort order as the
|
||||||
|
given object
|
||||||
|
* Greater than zero if the current instance follows the object given
|
||||||
|
|
||||||
|
All numeric types already have this, as do String Char and DateTime
|
||||||
|
|
||||||
|
=== System.IDisposable ===
|
||||||
|
|
||||||
|
Something that is IDisposable can be freed, it is very useful when working with
|
||||||
|
unmanaged resources, like database connections or filestreams. To impliment
|
||||||
|
this, a class must impliment `public void Dispose()`. This Dispose function
|
||||||
|
will be called if the object is used in a `using()` block statement for
|
||||||
|
example.
|
||||||
|
|
||||||
|
=== System.IEnumerable ===
|
||||||
|
|
||||||
|
Something that is IEnumerable can be used with an enumerator object. This
|
||||||
|
allows some object to work with LINQ queries. IEnumerable also requires
|
||||||
|
`IEnumerator<T>` to be defined. `IEnumerator<T>` also needs
|
||||||
|
[[#System.IDisposable]] to be implimented.
|
Loading…
Reference in New Issue
Block a user