Smarter Visual Studio 2008 IDE and compiler

by volkanuzun 2/26/2008 4:50:00 AM

Visual studio 2008 is really smart :), it catches a lot of things such as never assigned variables, never used varriables, not reachable part of code kinda thinga. However i wish it has one more check that could save my time on debugging a code :) Below is the code, i was struggling, see if u can catch it :)

public class clsStudent
{
    #region Member Variables
    public int ID_;
    public int ID
    {
        get { return ID; }
        set { ID_=value;}
....
....
}


Ok now where is the problem :)), the problem is get{return ID;} instead of get{return ID_}. Ok i admit that it was first of all my mistake to name those 2 variables very familiar, however isnt it obvious that this a deadly endless recursive call that visual studio should catch ? It doesnt catch it and if you run the code you will get a stack overfill error or something like this.

For those who cant see the bug, return ID; is calling get{return ID} again, and it happens again and again......

Anyways if you use automatic properties u wont have this problem, but our servers arent .net 3.5 yet :)

Tags:

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



About the author

Volkan Uzun




E-mail me Send mail

Twitter

Calendar

<<  December 2008  >>
MoTuWeThFrSaSu
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar

Flickr Badge

www.flickr.com
This is a Flickr badge showing public photos from volkanuzun. Make your own badge here.

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Sign in