接口可以是函数的返回类型.如果是的话那就是优势.例如,以下代码更正在返回接口数组的位置.
public interface Interface
{
int Type { get; }
string Name { get; }
}
public override Interface[] ShowValue(int a)
{
.
.
}
Run Code Online (Sandbox Code Playgroud) 我有点新,c#所以如果你觉得它很琐碎,请忽略.我看到了以下"奇怪"的代码.
任何人都可以对此有所了解.
public event Action _action;
if (_action != null)
{
foreach (Action c in _action.GetInvocationList())
{
_action -= c;
}
}
Run Code Online (Sandbox Code Playgroud)
特别是_action -= c;部分.
我遇到了一个代码.任何人都可以对此有所了解.如果有人发现它有点基本,那就好.
string str= String.Format("{0,2:X2}", (int)value);
Run Code Online (Sandbox Code Playgroud)
感谢您的时间.
我想在UserControl中执行以下操作:
foreach(Control c in this.Controls)
{
if(c is CheckBox)
{
// Do stuff here
}
}
Run Code Online (Sandbox Code Playgroud)
但是我得到了错误:
错误1找不到类型或命名空间名称'Control'(您是否缺少using指令或程序集引用?)
错误2找不到类型或命名空间名称'CheckBox'(您是否缺少using指令或装配参考?)
谢谢你的指导.