类名修饰函数名
private void accept()
{
Console.WriteLine("请输入实数部分");
_real=int.Parse(Console.ReadLine());
Console.WriteLine("请输入虚数部分");
_imaginary=int.Parse(Console.ReadLine());
}
void showresult()
{
Console.WriteLine("相加之和为:");
Console.WriteLine(_real+"+"+_imaginary+"i");
}
ComplexNumber Add(ComplexNumber objparam1)
{
objparam1._real+=_real;
objparam1._imaginary+=_imaginary;
return objparam1;
}
public static void Main()
{
complexnumber objnumber1=new complexnumber();
complexnumber objnumber2=new complexnumber();
objnumber1.accept();
objnumber2.accept();
complexnumber objtemp=objnumber1.add(objnumber2);
objtemp.showresult();
}
请问一下。。这个add方法。为什么加了类名complexnumber
且complexnumber objtemp=objnumber1.add(objnumber2);是什么概念呢??