怎么重写类成员的toString()方法
如何重写类成员的toString()方法
有一自定义类如下:
如何在输出call.CallType.toString()时输出:"呼出"(即CallType=callOut)
而不是重写类call的toString()方法
------解决方案--------------------
自己在Call类写一个自定义方法就好了,干嘛一定要重写ToString
------解决方案--------------------
你明明是想重写枚举的tostring,怎么把自己想重写什么类型的东西都没有搞清楚呢?
------解决方案--------------------
public class call
{
private callType _callType{get; set;}
public string CallType { get { return _callType.ToString(); } }
public string CallerName{get;set;}
}
有一自定义类如下:
- C# code
public enum callType { callOut, callIn, callUnAnswer } public class call { public callType CallType{get;private set;} public string CallerName{get;set;} }
如何在输出call.CallType.toString()时输出:"呼出"(即CallType=callOut)
而不是重写类call的toString()方法
------解决方案--------------------
自己在Call类写一个自定义方法就好了,干嘛一定要重写ToString
------解决方案--------------------
你明明是想重写枚举的tostring,怎么把自己想重写什么类型的东西都没有搞清楚呢?
------解决方案--------------------
public class call
{
private callType _callType{get; set;}
public string CallType { get { return _callType.ToString(); } }
public string CallerName{get;set;}
}