Static methods

This commit is contained in:
Max Yankov 2013-08-17 23:09:21 +02:00
parent dd1a619360
commit 41ec7af8e5

View File

@ -523,6 +523,14 @@ namespace Learning
"\n------------------------------\n" "\n------------------------------\n"
; ;
} }
// Methods can also be static. It can be useful for helper methods
public static bool DidWeCreateEnoughBycles()
{
// Within a static method, we only can reference static class memebers
return bicyclesCreated > 9000;
} // If your class only needs static members, consider marking the class itself as static.
} // end class Bicycle } // end class Bicycle
// PennyFarthing is a subclass of Bicycle // PennyFarthing is a subclass of Bicycle
@ -551,7 +559,7 @@ namespace Learning
* Flags * Flags
* Attributes * Attributes
* Generics (T), Delegates, Func, Actions, lambda expressions * Generics (T), Delegates, Func, Actions, lambda expressions
* Static properties, methods and classes * Static properties
* Exceptions, Interfaces, Abstraction * Exceptions, Interfaces, Abstraction
* LINQ * LINQ
* ASP.NET (Web Forms/MVC/WebMatrix) * ASP.NET (Web Forms/MVC/WebMatrix)