Geeks With Blogs
Jonathan Starr's Blog Thoughts on C#, Ajax, WCF, LINQ, Agile et al.

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 C# , Software Design , Software Development | Back to top


Comments on this post: Surprising CLR Behavior

# re: Surprising CLR Behavior
Requesting Gravatar...
I've tried this and it not only compiles but also works as intended - doSomethingElse() is called.
Left by SinsI on Nov 24, 2008 2:11 PM

Your comment:
 (will show your gravatar)


Copyright © Jonathan Starr | Powered by: GeeksWithBlogs.net