我认为这是一个编译器错误.
使用VS 2015编译时,以下控制台应用程序编译并执行完美:
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var x = MyStruct.Empty;
}
public struct MyStruct
{
public static readonly MyStruct Empty = new MyStruct();
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是现在它变得很奇怪了:这个代码编译,但它会TypeLoadException在执行时抛出.
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var x = MyStruct.Empty;
}
public struct MyStruct
{
public static readonly MyStruct? Empty = null;
}
}
}
Run Code Online (Sandbox Code Playgroud)
你遇到同样的问题吗?如果是这样,我将在Microsoft提出问题.
代码看起来毫无意义,但我用它来提高可读性并实现消歧.
我有不同的重载方法,如
void DoSomething(MyStruct? arg1, string arg2)
void DoSomething(string arg1, string arg2) …
我有一个关于React和事件处理的简单问题.我的组件看起来像这样(基本上是一个表):
const MyList = ({ items, onBlur }) =>
<table onBlur={onBlur}}>
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>Publisher</th>
<th>Year</th>
<th>Author</th>
<th>System</th>
<th/>
</tr>
</thead>
<tbody>
{items.map(item => <MyListRow key={item.Id} item={item}/>)}
</tbody>
</table>;
Run Code Online (Sandbox Code Playgroud)
我希望只有当焦点超出表格时才会blur触发事件.相反,当事件失去焦点时,事件将触发表的每个子元素.
根据文档,React让焦点事件冒出来.
问题是:onBlur只有当焦点离开桌子时,我怎样才能触发我的方法?IOW:如何过滤掉并丢弃冒泡的不需要的事件,以便仅显示表示桌子失去焦点的事件?
c# ×1
compiler-bug ×1
coreclr ×1
dom-events ×1
html ×1
html5 ×1
javascript ×1
reactjs ×1
roslyn ×1