I come across what, in my opinion, is a mistake, and I'm just wondering if this is known about this problem or if it is not a problem and why.
A problem with read-only properties in a type when compiling with the VB.Net compiler in Visual Studio 2008.
The following are class definitions and a small C # program that will not compile. (And it’s correct not to compile IMHO, because the property specified in the delegate is read-only)
public interface ITest
{
bool PrivateBool { get; }
}
public class TestClass : ITest
{
bool privateBool = false;
public bool PrivateBool
{
get
{
return privateBool;
}
}
bool publicBool = false;
public bool PublicBool
{
get { return publicBool; }
set { publicBool = value; }
}
}
class Program
{
static void Main(string[] args)
{
TestClass tc = new TestClass();
}
}
VB.Net. ... . .
, , , , , CSharp .
Module Module1
Sub Main()
Dim tc As New TestClass()
Dim setP = New Action(Of TestClass)(Function(d As TestClass) _
d.PrivateBool = False _
)
setP.Invoke(tc)
End Sub
End Module
- , ?
, - , , , , .
, , , . , .
# ? , . , vb.net IDE.
, , , Invoke?
, , , , CLR NOOP. , undefined?
!