About construction
Class Student
{
Non-parametric construction
Public Student () {}
With parametric construction
Public Student (int age,string name,string ID)
{
This.age = age;
This.id = ID;
THIS.name = name;
}
This represents an instance of the current class, used to differentiate the entry and member variables
}
For construction, you can construct a function in a class
1. The method name is the same as the class name
2. No return value type
3. Main completion of the initialization method between objects
Method overloading
If more than one method in a class has the same method name, the parameter list is different, which is the method overload. Independent of return value type
Constituent method overloads
1. Different types
2. Different order of variables
3. Different number of parameters
Class 1:
Public void Play (Music music)
{
}
public void Play (Sprict sprict)
{
}
public void Play (song song)
{
}
Class 2:
Student stu = new Student ();
Stu.play (New Music ());
Stu.play (New Sprict ());
Stu.play (New Song ());
Method overloading!!!
One of the constructs is also a method overload
Interaction between objects
Cond.....................................................................................
C # in-depth class methods