可以将参数从一种方法带到另一种方法吗?
基本上,我想要做的是重命名一个方法(在我的例子中是- .WriteLine()
方法),有没有办法创建一个具有我想要的名称的方法,并让它接受另一个方法的参数,如下所示:
void Func(Take The parametes of The .WriteLine method) //This is the rename of the method
{
Console.WriteLine(place them here);
}
基本上,我想重命名一个方法。
发布于 2016-08-14 16:13:16
如果我没理解错的话,您所要做的就是将一个对象传递给Func
,该对象应该传递给WriteLine
方法。
void Func(string SomeParameter) //This is the rename of the method
{
Console.WriteLine(SomeParameter);
}
SomeParameter
将被传递给调用Console.WriteLine
的Func
方法。使用此函数如下所示:
Func("Hello World");
这将在输出屏幕上打印文本"Hello World“。
https://stackoverflow.com/questions/38944035
复制