在VB.NET中,有没有办法将DateTime变量设置为"未设置"?为什么它可以设置DateTime到Nothing,但没有能够检查它是否是Nothing?例如:
Dim d As DateTime = Nothing
Dim boolNotSet As Boolean = d Is Nothing
Run Code Online (Sandbox Code Playgroud)
第二个语句抛出此错误:
'Is' operator does not accept operands of type 'Date'. Operands must be reference or
nullable types.
Run Code Online (Sandbox Code Playgroud) 我有一个泛型方法,它有一些泛型类型的参数.我想要做的是,能够访问我的函数内的这个泛型类型参数的方法.
public void dispatchEvent<T>(T handler, EventArgs evt)
{
T temp = handler; // make a copy to be more thread-safe
if (temp != null)
{
temp.Invoke(this, evt);
}
}
Run Code Online (Sandbox Code Playgroud)
我希望能够在temp上调用Invoke方法,类型为T.有没有办法做到这一点?
谢谢.