Posted by: minhdotnet | July 10, 2009

Object/Collection Initializers in C# 3 & VB 9

Two of the features from C#3 and VB 9 that I like the most are object initializers and collection initializers.  In the old days before C# 3 and VB 9, when we want to create a list and add items to that list, we had to write a lot of code.  For example, let’s say that we would like to create some Products and store those Products in a list, we would write something like this:

// C#
Product p1 = new Product();
p1.ProductID = 1;
p1.ProductName = "Lakers 2009 Championship T-Shirt";
p1.UnitPrice = 29.99;

Product p2 = new Product();
p2.ProductID = 2;
p2.ProductName = "Lakers 2009 Championship Banner";
p2.UnitPrice = 199.99;
List<Product> products = new List<Product>();


‘ Visual Basic
Dim p1 As New Product()
p1.ProductID = 1
p1.ProductName = “Lakers 2009 Championship T-Shirt”
p1.UnitPrice = 29.99

Dim p2 As New Product()
p1.ProductID = 2
p1.ProductName = “Lakers 2009 Championship Banner”
p1.UnitPrice = 199.99

Dim products As New List(Of Product)

In C# 3 and VB 9, we can use the object initializer syntax together with the collection initializer syntax to instantiate a list and add items to the list at the same time:

// C# 3
List<Product> products = new List<Product>
new Product { ProductID = 1, .ProductName = “Lakers 2009 Championship T-Shirt”, UnitPrice = 29.99},
new Product { ProductID = 2, .ProductName = “Lakers 2009 Championship Banner”, UnitPrice = 199.99}

‘ VB 9
Dim products As New List(Of Product)
New Product() {New Product With { .ProductID = 1,  .ProductName = “Lakers 2009 Championship T-Shirt”, .UnitPrice = 29.99},
{New Product With { .ProductID = 2, .ProductName = “Lakers 2009 Championship Banner”, .UnitPrice = 199.99}

As you can see, the new syntax is much more concise and less verbose.

Posted by: minhdotnet | July 8, 2009

Google Chrome OS and the Future of Windows

Google just recently announced their new OS.  After reading the news surrounding the announcement, I was thinking about what this means to Microsoft and Windows.  I must admit that I’m a huge Microsoft fanboy.  Essentially, I use Microsoft’s products everyday (Windows, Office, Visual Studio…).  However, I do use Google for search (90% of the time vs. Bing) and email (GMail).  Those are no doubt great products from Google.  Nevertheless, I’m very skeptical about this Google OS.  As most of us know, Google’s strategy is to create applications that run inside of a browser instead of having client applications running on an OS (e.g. Windows, Linux, Mac OS).  That is why they’re implementing this Google Chrome OS.  I’m fine with the idea of having some applications running inside of a browser but I’m not so sure about other applications.  For example, how does a DVD/CD recording application work inside of a browser?  What about DVD-playback programs?  I know I know in the future everything will be in cloud so we won’t need DVDs or any kind of physical objects to store data.  I wouldn’t bet on having everything in the cloud just yet.  For now, I’ll stick to having my CDs, DVDs, and hard drives.

It will be interesting to see how the Google Chrome OS turns out.  Until then, Microsoft shouldn’t have to worry much.  Windows is so entrenched in the personal computing market that it would take a very very long time for any product to take over.

Posted by: minhdotnet | July 7, 2009

I’m turning 27!

I’m officially turning 27 tomorrow (July 7).  Wow, time just seems to fly by so quickly.  I’m not looking forward to getting older and I’m definitely not thrill about approaching the 30s:-).  However, I’m excited about the future.  Day be day, nothing seems to change.  However, things will definitely be different in a couple of years from now.  Overall, life is good right now.  I can’t ask for more.  I appreciate the company of all of my friends, my family, and especially my girlfriend – Thao.  So yeah…Let’s party this weekend.

Posted by: minhdotnet | May 22, 2009

Visual Studio 2010 Beta 1 Download

As some of you may have known, Microsoft just recently released the Beta version of Visual Studio 2010.  I have downloaded the ISO version and I will show the installation process in a future post.  You can get more information by visiting the Visual Studio 2010 web page.

Visual Studio 2010 Web Page

You can download Visual Studio 2010 Beta by going to the following links:

You can also read more about the news on Soma’s blog.

Posted by: minhdotnet | May 21, 2009

Hello world!

Hello everyone.  This is my first post in this blog.  I will mainly focus on software engineering and technology topics in this blog.  Occasionally, I will have something related to my personal life.