22/02/2010
Object oriented Program
- Object: an instance of a class
- Class: template that define the form of an object. It specifies both the data and the code that will be operate on the data.
- Member variables: the valuables declared inside a class
- Method: blocks of code that perform some kind of action or functions
- Instance Method
- Static Method
- Instance Method
- Member variables: the valuables declared inside a class
- Constructor: using for initializing the member of a class. (default value 0 or NULL or false)
*no return data type
ex.
class student
{
int studentID;
string studentname;
int studentage;
}
student s1, s2;
s1 = new student();
s1.studentID=10;
s2 = new student();
Console.WriteLine(s2.studentID);
result 0
ex.
student()
{
studentID = 10;
studentname = "ABC";
}
student s1, s2;
s1 = new student();
s2 = new student();
result s1 and s2: ID 10 name ABC
ex.
student()
{
Console.WriteLine("Hello");
}
student s1, s2;
s1 = new student();
result s1 ID 0 name NULL
Access specifiers
- private
- public
- protected
- internal
- protected internal
ex.
class one
{
int i;
int xyz()
{
return 10;
}
}
class two
{
public static void Main
{
one o =new one();
Console.WriteLine(o.i);
}
}
result 0
default: private
0 件のコメント:
コメントを投稿