April 2014
Intermediate to advanced
960 pages
22h 9m
English
This appendix provides information about method declarations. A property procedure includes a pair of methods, which are also described here.
In C# all methods must be inside a class. The syntax for creating a method is as follows.
«attributes» «accessibility» «modifiers» return_type name(«parameters»)
{
code...
}
The following list describes the pieces of this declaration.
public, internal, protected, internal protected, or private.new (hides a parent class’s version of the method), static (shared by all instances of the class), virtual (the method can be overridden in a descendant class), override (the method is overriding a version in an ancestor class), sealed (indicates an overriding method cannot be further overridden), abstract (defines only the method’s signature), or extern (the method is defined outside of the assembly).void.Use a return statement to exit the method and return a value (if the method returns a value).
Properties have get and set accessors. The syntax for creating a read/write property is as follows.
public data_type name
{
get
{
...
return value; } set ...Read now
Unlock full access