Professional Documents
Culture Documents
An introduction to coding
o the process of creating objects from classes is called
instantiation.
o Members of an object include properties, methods, and
events that defined by classes and are used by objects.
Properties – refers to the object’s characteristics and
data associated with the object.
Methods – these determine the operations that can be
performed by the object.
Events – represents signals sent by the object to your
application that something has happened that can be
responded to. For example, a “Button control” object
generates an event called “Click” if the user clicks the
button. Then the application can respond by running a
“Method” to handle the “Click” event.
o Classes and object concepts
An object is a self-contained unit that combines code
and data. In other words, an object can also be referred
to as an instantiation of a class. For example, objects
may include forms and controls (Button, Label).
A class is the code that defines the characteristics of an
object. In other words, a class can be called a template
for an object.
o When you use a form designer, VS automatically generates
C# code that creates a new class based on the Form class.
Then, when you run the project, a form object is instantiated
from the new class.
o Similarly, when you add a control to a form, VS automatically
generates C# code in the class for the form that instantiates
a control object.
How to add code to a form
o Coding rules
Use exact capitalization for all keywords, class names,
object names, variable names, etc.
End each statement with semicolon.
Each block of code must be enclosed in braces {}.
Use blank lines before and after groups of related
statements.
o A method written in a readable style: