diff --git a/tech/C-sharp.wiki b/tech/C-sharp.wiki index 40044bc..dacf08c 100644 --- a/tech/C-sharp.wiki +++ b/tech/C-sharp.wiki @@ -104,7 +104,7 @@ declare a class as `abstract`. To override a class add the modifier `override`. -== Interfaces == +== [[interface]] == 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. @@ -127,6 +127,8 @@ It provides some set functions to be implimented by the child class. } }}} +See [[interface]] + == Examples == === Hello World === diff --git a/tech/interface.wiki b/tech/interface.wiki new file mode 100644 index 0000000..3167fe8 --- /dev/null +++ b/tech/interface.wiki @@ -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` to be defined. `IEnumerator` also needs +[[#System.IDisposable]] to be implimented.