VB.Net, why is this not a mistake?

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();
        //Compile Error
        //tc.PrivateBool = false;

        //Compile Error
        //Action act = new Action(delegate()
        //{
        //    tc.PrivateBool = false;
        //});

        //Action<TestClass> test = new Action<TestClass>(delegate(TestClass tcc)
        //{
        //    tcc.PrivateBool = false;               
        //});

        //Compile Time Error
        //Action<TestClass> test = new Action<TestClass>( tz=> tz.PrivateBool = false);

        //Compile Time Error
        //Action test = new Action(tc.PrivateBool = false);
    }
}

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?

!

+5
1

VB.NET 2008 lambdas. - . , .

VB d.PrivateBool False .

. lambdas VB.NET 2008 Action, .

lambdas VB.NET 2010.

+5

All Articles