public 方法A()
{}public 方法A(string str)
{
string myStr=str;
}public 方法A(object obj)
{
object myObj=obj;
}public 方法A(string str,object obj)
{
string myStr=str;
object myObj=obj;
}最后一个方法A(string str,object obj)是方法A(string)和方法A(object)一起执行,虽然可以这样写,但是,我记得C#里面可以进行base的继承的,相当于,同时继承2GE方法
{}public 方法A(string str)
{
string myStr=str;
}public 方法A(object obj)
{
object myObj=obj;
}public 方法A(string str,object obj)
{
string myStr=str;
object myObj=obj;
}最后一个方法A(string str,object obj)是方法A(string)和方法A(object)一起执行,虽然可以这样写,但是,我记得C#里面可以进行base的继承的,相当于,同时继承2GE方法
{
public 方法A():this("")
{
} public 方法A(string str):this(str,null)
{ } public 方法A(object obj):this("",obj)
{ } public 方法A(string str, object obj)
{
string myStr = str;
object myObj = obj;
}
}
如果是你这样做的话,myStr就被赋值“”这个了。实际上,某个时候,方法2和方法3需要单独执行,并且之间的变量没有影响。
public 方法A()
{} public 方法A(string str)
{
string myStr=str;
} public 方法A(object obj)
{
object myObj=obj;
} //我现在是这样做的,只是觉得还不是很爽。
public 方法A(string str, object obj):this(obj)
{
string myStr = str;
}
}
{
Console.WriteLine("this function has no param");
} public void a(string str)
{
Console.WriteLine(" this function has a param str");
} public void a(object obj)
{
Console.WriteLine(" this function has a param obj");
} public void a(string str, object obj)
{
Program p = new Program();
p.a(str);
p.a(obj);
}
这样做似乎也有点 .... 但是符合你的要求哦!
{} public 方法A(string str)
{
string myStr=str;
} public 方法A(object obj)
{
object myObj=obj;
} public 方法A(string str,object obj)
{
string myStr=方法A(str);
object myObj=方法A(obj); }
{
public void 方法A()
{}
public void 方法A(string str)
{
string myStr = str;
}
public void 方法A(object obj)
{
object myObj = obj;
}
public void 方法A(string str, object obj)
{
方法A(str);
方法A(obj);
}
}
{
// 公有构造函数,不需改动: public 方法A()
{
}
public 方法A(string str)
{
私有方法A(str);
}
public 方法A(object obj)
{
私有方法A(obj);
}
public 方法A(string str, object obj)
{
私有方法A(str);
私有方法A(obj);
}
// 以下是私有方法A,如果需要改动,只要改动以下2个私有方法:
private void 私有方法A(string str)
{
string myStr = str;
}
private void 私有方法A(object obj)
{
object myObj = obj;
}
}