c#class:
public class AClass<T> where T : INterFace
{
public static float m_var = 0.91F;
...
}
VB.NET类
Public Class AnotherClass
...
Public ReadOnly Property V As Single
Get
Return AClass(Of XX).m_var
End Get
End Property
End Class
XX是一个类(实现INterFace)
不知道为什么我看不到这个 - 我收到一个错误:
“m_var is not a member of AClass(Of XX)
”
我也尝试过使用c#版本:
public class AClass<T> where T : INterFace
{
private const float m_var = 0.91F;
public static float VV { get { return m_var ; } }// change name in VB as needed
...
}
答案 0 :(得分:0)
这很好用,请注意[INterface]上的括号,因为它是VB中的保留字(不像C#那样区分大小写)
<强> C#强>
public interface INterface
{
}
public class AClass<T> where T : INterface
{
public static float m_var = 0.91F;
}
<强> VB 强>
添加对C#项目的引用
Imports MyCSharpNamespace
Public Class AnotherClass
Public ReadOnly Property V As Single
Get
Return AClass(Of XX).m_var
End Get
End Property
End Class
Public Class XX
Implements [INterface]
End Class