我有一个接口
I
OldMethod
NewMethod
相反。因此,我延长了
具体如下:
Interface I
<Obsolete("Use NewMethod instead.")>
Sub OldMethod()
Sub NewMethod()
End Interface
但是,现在我所有的课
我
获取编译器警告:
Class C
Implements I
' The following line yields warning BC40000
Public Sub OldMethod() Implements I.OldMethod
Throw New NotImplementedException()
End Sub
Public Sub NewMethod() Implements I.NewMethod
Throw New NotImplementedException()
End Sub
End Class
这对我来说毫无意义:实施
我
(整体而言
过时),我
实施
. C#中相应的代码编译得非常好,不会产生警告:
interface I
{
[Obsolete("Use NewMethod instead.")]
void OldMethod();
void NewMethod();
}
class Explicit : I
{
public void NewMethod() { throw new NotImplementedException(); }
public void OldMethod() { throw new NotImplementedException(); }
}
class Implicit : I
{
void I.NewMethod() { throw new NotImplementedException(); }
void I.OldMethod() { throw new NotImplementedException(); }
}
suppress the warning in VB
,但是,通常,编译器警告指示您正在执行不应以这种方式执行的操作。
如何在VB.NET中实现具有过时成员的接口,而不会收到过时的警告?