0

Smarter Visual Studio 2008 IDE and compiler

by volkanuzun 26. February 2008 10:50

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:

Comments are closed

Powered by BlogEngine.NET 1.6.0.0
Original Design by Laptop Geek, Adapted by onesoft