如何传递变量来覆盖toString()方法? [英] How to pass variables to overridden toString() method?
本文介绍了如何传递变量来覆盖toString()方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能在布尔
变量传递到重写的toString()
方法,因此它可以有条件地打印对象的不同格式?
Is it possible to pass in a bool
variable into an overridden toString()
method, so it can conditionally print the object in different formats?
推荐答案
您可以定义的超载的方法的ToString()
。
public string ToString(bool status){
//
}
这篇关于如何传递变量来覆盖toString()方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文