|
I always hear how VB is soooo verbose and sooooo hard on the eyes... Well I have had it with C# this week.
Please explain to me why in the VB.Net code editor you can select a control on a form from the drop down box on the left and then select the method, etc... that you want to write code for from the drop down on the right and get the shell of the code built for you in the code window, or be taken to where it already exists.
...but in C# all you see in the left drop down in the current parent object that you are in (IE: class, form, etc…) and the right drop down box either only shows you a listing of controls on that form, or methods of the class, but NOT a listing of controls placed on the form?
I don’t get it. What is wrong with the way the VB editor works?
You C# guys need to declare a delegate and attach it to a control, blah blah blah...
All the VB person has to do is select and click and we get the darn code done for us.
Oh yeah, and before you start yelling about connecting multiple handlers to an event, all I have to do in VB is add a Handles clause to the end of my event handler to attach the other control(s) and if I am good, I also modify the name of the method to be more generic, and I am DONE!
Grrrrrrrrrr
Done venting now...
|
|
|
|
|
Are you still using the old crap way of event handling? Haven't you heard of weak events? Oh wait "Handles" doesn't handle that.
|
|
|
|
|
Talk about 'weak events'... I think that pun qualifies
|
|
|
|
|
Totally agree.
Although I'm using more C# than VB.NET I totally agree with Ray, VB.NET editor is superior as far as helping you with the code.
It also shows a comprehensive list of events implemented for that particular control.
Not to mention the right arguments types for the event handler.
|
|
|
|
|
Ray Cassick wrote: drop down box on the left
Ray Cassick wrote: left drop down
Ray Cassick wrote: right drop down box
Ray Cassick wrote: a listing of controls placed on the form
Umm, what? I don't follow. Any VB can do, C# can do better.
|
|
|
|
|
well, there are a couple of differences in the way Visual Studio helps the programmer. In VB.NET the class drop-down (on top of the source edit windows) shows its content hierarchically, so one sees a list of the controls, in C# it doesn't do that, it behaves like a simple ComboBox. Maybe the designers just had some spare time or they thought the VB people needed more help?
|
|
|
|
|
Luc Pattyn wrote: ... or they thought the VB people needed more help?
I think you're on to something, Luc. I've never had problems finding methods and events in C# and never used the drop down in VB.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
|
I only recently changed to C# but was not even aware of the IDE capability, then again I am continually amazed at the shortcuts that I don't know of. Just vetting the way another programmer does their work reveals little insights all the time.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
So, not like the alphabetical list at the top of the Properties pane? Which I hardly ever use?
|
|
|
|
|
I finally got around to creating a WinForms solution (VS2008) in VB.net and I don't see what you're talking about -- it looks pretty much the same as a C# solution; except C# solutions/projects don't hide files from me.
|
|
|
|
|
if it is a WinForm project, add some Controls to the Form, and they appear in the drop-down at the top left of the edit window in VB.NET, they don't in C# (I'm using Express Editions here).
VB.NET Express hides files by default, clicking one of the buttons above the solution pane remedies that.
|
|
|
|
|
Luc Pattyn wrote: add some Controls to the Form
Yep, did that.
Luc Pattyn wrote: and they appear in the drop-down at the top left of the edit window in VB.NET
I don't see it... ohhh... that. I don't usually have the Navigation Bar (never heard of it before now) turned on in C#; it seems fairly pointless, trying it on for size now. Yeah pointless, only useful if you define multiple classes in one file -- which you shouldn't do.
And they don't let you turn off the Navigation Bar in VB?!
|
|
|
|
|
I typically have only one class in a file, and I only use the righthand drop-down, which lists methods and properties. That is quite useful IMO.
I don't remember having ever changed the setting about nav bars, and they are present for me both in VB.NET and C# (Express!)
|
|
|
|
|
I guess you can't blame the language. If the C# editor lacks some features, you should blame the editor. Both languages are different, with pros and cons. I prefer C# for almost everything, but I still use VB for some very concrete things which result easier than in C#.
|
|
|
|
|
Agreed... I have no problems with C#. I use it all the time. I just am aggravated with the inconsistencies of the editor. It’s not the languages fault, and I didn’t intend for it to sound like that.
See my reply below to PIEBALDconsult about what I am really ticked at here…
|
|
|
|
|
Ray Cassick wrote: get the shell of the code built for you
Either by double-clicking the control in the designer or by selecting an event from the properties pane.
|
|
|
|
|
Yeah, now see... that to me is an oddity...
Just double-clicking in the control provides you with a default event handler (in all honesty just like the VB editor does the same thing) but to get a handler for a different event you need to then go over to where the properties window is, select the button to display the events available, find the event type you want in the list and click it to see it.
Yes, I agree that you CAN ALSO do the same thing in a VB project.
I am just aggravated that for a company that tries to preach visual and usability consistency in their documentation, they go and do this. They made the UI for a C# code editor window and a VB code editor window behave in different ways.
WHY?
Trust me, I am in no way slamming C#. I LIKE the language. It’s fine for when I use it, and it gets the job done. YES, my first choice is to use VB if I can, JUST because I am used to it over the years, but I can play in both areas just fine code/concept wise.
It just aggravates me that in this day and age MS is still not following their design philosophies.
Surprised? No.
Aggravated? Yes.
Something as basic as the organization of a code editor window, in my opinion, should be a standard that the developers HAVE to follow. It would be stupid to expect a VB developer to use Ctrl+C for the copy command and then expect the C# developer to use a different command right? In fact it is against every tenant that MS establishes, but they STILL allow this kind of junk to happen within their own development teams.
Maybe the C# devs feel the ‘VB way’ of doing it is stupid or childish, or inefficient, or whatever, but the simple fact is that MS obviously little control over what their devs implement and this shows it. Here we are, VS2010 and we still see creepy differences like this.
I wonder if Eclipse or SharpDevelop have inconsistencies like this?
|
|
|
|
|
publc class Thing
{
Thing () {}
public List<Foo> MyFoos {get; set;}
}
<pre>
How do you get the list to be defaulted to an empty list rather than null? Do I need to implement a private backing variable?
|
|
|
|
|
Either use a backing field and lazy initialization
public class Thing
{
private List<Foo> m_List;
Thing() { }
public List<Foo> MyFoos
{
get
{
if(m_List == null)
m_List = new List<Foo>();
return m_List;
}
set{ m_List = value; }
}
or use the constructor
public class Thing
{
Thing()
{
MyFoos = new List<Foo>();
}
public List<Foo> MyFoos {get; set;}
}
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Excellent answer... (Because I do it this way, of course.)
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Do you have to do it in every constructor? I put it in the default constructor but it doesn't seem to work when I instatiate using a different constructor.
|
|
|
|
|
You need to append :basename() to the constructor definitions.
public class MySuperAwesomeClass
{
public int AwesomeOne { get; set; }
public int NotAsAwesome { get; set; }
public string UselessCrap { get; set; }
public MySuperAwesomeClass()
{
AwesomeOne = 42;
NotAsAwesome = -1;
}
public MySuperAwesomeClass( string someValue ) : base()
{
UselessCrap = someValue;
}
}
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Appending :base() doesn't run the default constructor for that class. The debugger never enters the default constructor and all my list properties are still null if I instantiate using a different constructor.
|
|
|
|
|
Rather than append :base() , you should use :this() to call the default constructor in the current class. The use of base implies a call to a base class, whereas this refers to the current class.
|
|
|
|