我有这样的事情:
public [What Here?] GetAnything()
{
Hello hello = new Hello();
Computer computer = new Computer();
Radio radio = new Radio();
return radio; or return computer; or return hello //should be possible?!
}
Run Code Online (Sandbox Code Playgroud)
我有一个方法,这个方法有时会返回不同类型的值(类).
我怎么能这样做,以后再使用变量,是radio.Play(); 到目前为止?
我需要使用泛型吗?怎么样?