User classes
Posted: 16 Jul 2014, 06:42
User class is object consisting of properties and methods.
In OOP, you use objects=classes in your programs to encapsulate the data associated with the entities with which the program is working. For example, a human resources application needs to work with employees. Employees have attributes associated with them that need to be tracked - names, addresses, departments, and so on. Although you track the same attributes for all employees, each employee has unique values for these attributes.
Along with the properties you also need an established set of behaviours exposed by object (class). For example, one employee behaviour of interest to the human resources department is the ability to request time off. The Employee object contains a RequestTimeOff method that encapsulates the necessary code.
A class enables you to create your own custom types by grouping together variables of various types and methods. A class is like a blueprint. It defines the data and behavior of a type. You can use it by creating instance which are assigned to a object variable.
UserClass declaration:
class <Class_Name> {
<Class_Properties>
<Class_Methods>
}
Initialise:
object <Varianble_Name> = new <Class_Name>();
Use:
User class can be used to encapsulated logic block of properties (values) and functions.
You can create multiple instances of one class type to make script clear, readable and more efficient.
See also:
url=http://msdn.microsoft.com/en-us/library/vstudio/x9afc042.aspxMSDN online help/url.