Tuesday, September 30, 2008

Type Initializers in C# 3.0

This is really cool. C# version 3.0 has a new syntax for instantiating an object as well as setting a bunch of initial properties and values on it. This works for regular types as well as lists and dictionaries.

Look at this sample code below.

// Regular object initialization

// C# 2.0 and earlier

SaveFileDialog dialog = new SaveFileDialog();
dialog.CheckFileExists = false;
dialog.CheckPathExists = true;
dialog.OverwritePrompt = false;

// C# 3.0. Not a huge savings on lines, but less language clutter over all

var dialog = new SaveFileDialog
CheckFileExists = false,
CheckPathExists = true,
OverwritePrompt = false

// --------------------------------

// List initialization

// C# 2.0 style

List<string> stringList = new List<string>();

// C# 3.0 style
var stringList = new List<string>{ "FOO", "BAR", "BAZ", "BANG" };

// --------------------------------

// Dictionary initialization

// C# 2.0 style

Dictionary<int, string> employeeNameMap = new Dictionary()<int, string>();;
employeeNameMap .Add(1, "Sally");
employeeNameMap .Add(2, "Tim");
employeeNameMap .Add(3, "Joe");
employeeNameMap .Add(4, "Jane");

// C# 3.0 style

var employeeNameMap = new Dictionary<int, string>
{1, "Sally"}, {2, "Tim"}, {3, "Joe"}, {4, "Jane"}

Reference URL: CSharp Type Initializers in C# 3.0

Monday, September 29, 2008

jQuery, Microsoft, and Nokia

jQuery team have two pieces news today: Microsoft and Nokia are taking the major step of adopting jQuery as part of their official application development platform. Not only will they be using it for their corporate development but they will be providing it as a core piece of their platform for developers to build with.

Here is the link:

Friday, September 26, 2008

C# typeof - How it works?


The typeof operator is used to obtain the System.Type object for a type. A typeof expression takes the form:


type The type for which the System.Type object is obtained.


The typeof operator cannot be overloaded.

To obtain the run-time type of an expression, you can use the .NET Framework method GetType.


// cs_operator_typeof.cs
// Using typeof operator
using System;
using System.Reflection;

public class MyClass
public int intI;
public void MyMeth()

public static void Main()
Type t = typeof(MyClass);

// alternatively, you could use
// MyClass t1 = new MyClass();
// Type t = t1.GetType();

MethodInfo[] x = t.GetMethods();
foreach (MethodInfo xtemp in x)


MemberInfo[] x2 = t.GetMembers();
foreach (MemberInfo xtemp2 in x2)


Int32 GetHashCode()
Boolean Equals(System.Object)
System.String ToString()
Void MyMeth()
Void Main()
System.Type GetType()

Int32 intI
Int32 GetHashCode()
Boolean Equals(System.Object)
System.String ToString()
Void MyMeth()
Void Main()
System.Type GetType()
Void .ctor()
Referecence URL:

Thursday, September 25, 2008

Project 10^100 by Google

My previous Project Manager sent me this link Project 10 to the 100. Please watch the video below and see what this project is all about.

Tuesday, September 23, 2008

How to get the path to my running EXE and DLL?

If you want to get the path of the running EXE of your project you might need to use this code.


The Application class has a static member ExecutablePath that has this information.

string appPath = Application.ExecutablePath;  

Howerver if you want to get the path of the executing assembly here is the code.


Also, there are a number of ways to get the app.path in VB.NET. This particular method works for VB.NET (including windows forms applications and .dlls) and ASP.NET. Unlike App.Path in VB6, this includes the the "\" at the end of the value.

Declarations: none
Public Function App_Path() As String         
Return System.AppDomain.CurrentDomain.BaseDirectory()
End Function

Friday, September 19, 2008

.NET BlogEngine open source

For those who are still looking for a open source .net blog framework. I think this is what you're looking for. Enjoy blogging! :)

BlogEngine.NET is an open source .NET blogging project that was born out of desire for a better blog platform. A blog platform with less complexity, easy customization, and one that takes advantage of the latest .NET features.

BlogEngine.NET was designed using the current .NET framework and focused on simplicity, ease of extendibility, and innovative features. With BlogEngine.NET, we hope to create the natural blog of choice for all .NET developers world wide.

Wednesday, September 17, 2008

Back to the Future

I was searching for the old website of Microsoft just to see how it looked back then, and guess what I found? A bunch of old web designs of famous websites today. I really appreciate how the technology changes so fast. Take a look of these images to see what I mean.
Microsoft 1994
microsoft 1994
Microsoft 1995
microsoft 1995
Microsoft 1996
microsoft 1996
Youtube 2005
youtube 2005
Yahoo 1996
yahoo 1996
Wikipedia 2001
wikipedia 2001
MSN 1996
msn 1996
Live 1998
live 1998
Google Inc. 1998
google 1998
Facebook 2005

Monday, September 15, 2008

Hug a Developer!

Someone has sent me this link and I find it very funny. They said that the developers everywhere are in terrible pain. I think you will enjoy watching this video. So here it goes...