Hi again, C# gurus. Total beginner ellpee is back with a brainteaser for you. I'm still in C# kindergarten, experimenting in Visual Studio with some rudimentary console projects, and have noticed something really odd.
To set the stage, imagine I'm starting from scratch and trying to write a simple solution. First I set up a namespace with its curly brackets, and inside that I declare a class with its curly brackets, and inside that I write some code, some of it with curly brackets. That brings me to here:
NOW THEN, to the quirky part. Sometimes, when I write code to fit between the various sets of curly brackets, the code editor goes rogue and deletes the closing curly bracket for the class section, and that results in a bunch of squiggly underlines and other error flags in my code. By trial and error, using the undo key and/or commenting out lines of code, eventually I get back to a point where the missing class bracket magically reappears and I can try something else to get me to my goal.
So what I'm wondering is not so much what code statements are to blame, that seems to vary from one time to the next. But I'm just curious why does the code editor take it upon itself to remove that important curly bracket. Seems to me all the squigglys and screwdrivers and lightbulbs ought to suffice to tell me I got something wrong and need to fix it; I don't get the point of the "curly bracket cure." Can anyone enlighten me?
To set the stage, imagine I'm starting from scratch and trying to write a simple solution. First I set up a namespace with its curly brackets, and inside that I declare a class with its curly brackets, and inside that I write some code, some of it with curly brackets. That brings me to here:
C#:
namespace myNS
{
class myClass
{
//maybe some simple code here, e.g., variables
//then let's throw in a simple constructor
public void myClass(int myint, double mydouble, etc.)
{
//some more simple code here for constructor purposes
} //closing curly bracket for constructor object
} //closing curly bracket for class
} //closing curly bracket for namespace
So what I'm wondering is not so much what code statements are to blame, that seems to vary from one time to the next. But I'm just curious why does the code editor take it upon itself to remove that important curly bracket. Seems to me all the squigglys and screwdrivers and lightbulbs ought to suffice to tell me I got something wrong and need to fix it; I don't get the point of the "curly bracket cure." Can anyone enlighten me?
Last edited by a moderator: