Friday, July 08, 2005

Some more 'HOT' features of studio 2005

The Beta has been driving me nuts! it's a dream come true for any Developer. Here are some more really HOT features to watch out for:
- Code Snippets - Sleek and smart!!! The way the snippets are inserted is cool but what really blew me off was the way varaible names changed when i changed specific part of the pre-insterted template!
- Refactoring - Some mind blowing features here. What i like most if i no longer need to type the same lame code to create properties.
- Partial Classes - Sleek and neat organization of code. Now two of us could be working on the same class at the same time but still stay on seperate files without worrying about screwing up each others work. The only thing that made me knit a brow slightly was the fact that i had to declare all my fields in a single file or else studio kept firing a warning. hmmm... must be some reason behind it i cant catch.

Custom Classes are NOT Value Types...

This is for all the confusion that is often caused due to a commonly made mistake all of us make at some point of time - Classes are NOT Value types! In other words when you assign an object of a class to a variable you are assigning a reference and not a 'copy' of the value! So, basically a change in either one of the objects now reflects in both. Followin Code snippet illustrates:

Employee rajivpopat = new Employee();
rajivpopat.EmployeeName = "rajivpopat";
rajivpopat.EmployeeDOB = System.Convert.ToDateTime("11/24/1981");
rajivpopat.AdditionalContactDetails = "AdditionalDetails";

Employee chetanpopat = rajivpopat;
chetanpopat.EmployeeName = "chetanpopat";
MessageBox.Show(rajivpopat.EmployeeName);
This shows and output "chetanpopat" - because change of chetanpopat.EmployeeName = "rajivpopat" has changed the vallue that rajivpopat.EmployeeName was referencing!!!

Structs however, work with a different concept and are Value Types! The Same code would return "rajivpopat" if Employee was defined as a struct! You'll not be able to initialize values of fields in struct and they will all be initialized by default value!!!