Difference between revisions of "Class"
Kspriggs01 (talk | contribs) (→Definition) |
Kspriggs01 (talk | contribs) (→Definition) |
||
Line 7: | Line 7: | ||
Classes can inherit properties and methods from other classes if they are a '''child''' of that class. This concept is known as '''Class Inheritance'''. | Classes can inherit properties and methods from other classes if they are a '''child''' of that class. This concept is known as '''Class Inheritance'''. | ||
− | |||
==How to Create a Class== | ==How to Create a Class== |
Revision as of 19:45, 8 February 2020
Contents
Definition
A class is like a blueprint for an object, it defines what kind of information it has to have and what kinds of things it will be able to do.
Inside a class declaration, there can be fields, properties, methods, and events.
Each class should be designed to only accomplish one specific task, therefore a complete program will use many different classes.
Classes can inherit properties and methods from other classes if they are a child of that class. This concept is known as Class Inheritance.
How to Create a Class
You can choose to create a new .cs file in order to store your new class, or you can declare it within the same .cs file as another class. The former is recommended so you can clearly identify which files correspond to which classes.
Classes can be static, abstract, and/or partial.
Access modifiers that are applicable to methods and variables are also able to be used in their declarations (such as public, private, or protected).
Each class needs to have an identifier set for them, just like with variables.
Relevance
Resources
See also
- Object
Additional Links
Programming Tutorial: Classes Part 1
Programming Tutorial: Classes Part 2