Posts
70
Comments
66
Trackbacks
0
Surprising CLR Behavior

improve my => 'code' Add to Google

The following code (surprise, surprise) compiles.  But it does not work as intended  (you won't be able to "doSomethingElse()!

Can any of you figure out why?  (I have my suspicions.)

Jonathan Starr

using System;

namespace test

{

    internal class BaseTest

    {

        private int _prop1;

        public virtual int prop1

        {

            get { return _prop1; }

            set { _prop1 = value; }

        }

    }

 

    internal class DerivedTest : BaseTest

    {

        public override int prop1

        {

            set { base.prop1 = value; doSomethingElse(); }

        }

    }

}

 

posted on Friday, January 25, 2008 4:45 PM Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 8 and 6 and type the answer here:
News
Jonathan Starr is a developer in Saint Louis, MO. He holds an MBA in Finance from Columbia Business School and earned his MCSD from Microsoft.


All statements in this blog are personal opinions and do not reflect the opinions of his employer.





Related Sites
Join My Community at MyBloglog!

Tag Cloud