Geeks With Blogs
Joaquin Jares Just another geek's blog
I finally did it. I mean, I know I should have done this a long time ago, but last week I finally did it. I went to microsoft's page, downloaded Visual C# Express and installed it.

I must say, my first impression was absolutely positive.

As a windows geek, the first thing I did was to create a new empty Windows Forms project. And just to see what was on it, I compiled it and disassembled it on ILDASM.

There where two things that I found unusual and beautiful. First thing was inside ILDASM, and second thing was outside it.
Let me explain:

The first thing I saw, was that there where two classes in my main Namespace: Form1 and Program. Form1 I already knew, Program I didn't know. So I went into Program, to see what that was about. And I liked it, I really did!
In a blank C# Windows Forms project, Program has the void main() function, working as a startup. Traditionally this was the job of the very first form you added to the project (added by default in Visual Studio). The thing I love about the new approach is that I never liked the way it used to work, but I didn't think about it until I saw the new way. First thing I thought is "someone is taking the job of anticipating my thoughts for me".
The advantages of this approach are obvious: if you have to delete the first form for some reason, the void main() remains in the project. If you need to hide that form (as in a spash window), you'll have to either take the main function to a new class, or have a resident form for the duration of the application. But that's not what I like about Visual C# Express providing it for me. What I like is that someone thought it'll be a cool feature, and he added it though it didn't look like the great thing...

So I went to the form class to see what it looked like, and I found the second great thing: Partial Classes.

Partial classes are to me another of the "removing little inconveniences" new features. They don't add much, but then again, they do.
Anyway, what I saw was that the InitializeComponents was nowhere to be seen. So I opened the little branch coming from Form1.cs in the Solution Explorer, and there I saw two new objects: Form1.Designer.cs and Form1.resx. Form1.resx I knew; that was the resources file. It wasn't there in previous versions (explicitly at least), but it was pretty obvious that was it. The other one looked like code, so I went and double-clicked it. And there it was, InitializeComponents in a different part of the code, but in the same form.
For those who don't know what Partial Classes are, a really simple explanation: they are the new way of defining a single class in multiple parts of the code. You simply add a "partial" keyword to any class definition, and you write some more code to it. There are quite a few restrictions, but it's still a great thing. To understand the restrictions, you must understand that Partial Classes are just Regions on steroids. You can't redefine an existing method, you can't change the scope of the class. You can define new internal members, new properties, new methods, new events... whatever you like as long as you don't alter anything defined elsewhere. Partial classes are not ment to provide new functionality. On the contrary, they are ment to separate functionality. For instance, all the stuff that the Form Designer adds for you ends up in the Form1.Designer.cs module, as part of Form1.

So why is this a great thing? Same reason as the new Program class is a great thing: neatness. In previous versions, the things the Form Designer did where mixed with your code. And you could end up accidentally changing it. Or worst, it was almost completely hidden from you (as when creating a typed dataset). Everything is now shown and everything is now separated.

Once again, it doesn't add much. But I really do like it. I like it so much, I think I'll be blogging about it again! Posted on Tuesday, October 25, 2005 9:11 PM | Back to top


Comments on this post: Visual C# Express 2005

# re: Visual C# Express 2005
Requesting Gravatar...
Welcome Joaquin, I will enjoy your posts.
Left by Pablo Galiano on Oct 25, 2005 9:22 PM

# re: Visual C# Express 2005
Requesting Gravatar...
I agree completely!
Visual C# Express 2005 is just what i was waiting for!
It's simple, powerful, and beautiful!
Hurray for C# Express 2005!!
Left by Eric Van de Kerckhove on Dec 26, 2005 4:17 PM

Your comment:
 (will show your gravatar)


Copyright © Joaquin Jares | Powered by: GeeksWithBlogs.net