myfavoritemovies.us

February 27, 2009

C# 4.0 New features – Optional/Default values in Method calls

Filed under: C# 4.0 — @ 7:18 pm

I been wanting this feature in C# for some time. I am happy they are going to implement it in C#4.0. Even though C# has some very new cool features, I think this is one of the feature that ordinary programmer would use everyday. There are times I do not want pass a parameter to a method. If the parameter is not passed, I want it to get a default values. In C#3.0 we can not do it. The solution to this problem is to write wrappers for each missing parameters and then assign the default value and then call the actual method. It was ok, but too many Unit tests and add more lines of code for possible bug somewhere.

With this new feature we can get the best of what other languages were enjoying for sometime. Lets look at a example

public class Personal

{

        public int GetEmployeeListing(string name = “*”,

                       int age = 20,

                      char sex = ‘f’)

      {

      …

     }

   static void Main()

  {

      Console.WriteLine(GetEmployeeList(age:30));

      Console.WriteLine(GetEmployee(sex:’m’, age=25);

  }

 

As you can see in the above example, ‘GetEmployeeListing’ takes 3 parameters and all of them have default values. So in the Main when we invoke the write WriteLine method, we passed only the age field, thus using name and sex to default value. The second call shows one additional benefit of this definition, parameters are not absolute anymore once you name them. In this case, we change the order and passed sex and age so when the program it name will take the default value.

Of all the features I read, this one will be the one used heavily but again, it is too soon to guess anything.

February 24, 2009

IE8 Beta crash!

Filed under: Uncategorized — @ 3:18 pm

I have been using IE8 Beta for some time now, I really enjoy all the cool new features they have implemented in it. The Addon features for social networking was very good and I used them a lot. Anyway, the point I was getting at is the IE8 crashes. If you cut and past the URL text in to address bar, IE8 crashes.  One good news is IE8 is ability to restore to its last known state and that is also a very good feature I love. Since I wasn’t doing lot of URL pasting, I didn’t pay attention to it at all. I have safari (I know what you are thinking Safari???, I use Mac at home) so I was ok.

Yesterday I was doing some research and I had the same crash. So I decided to hunt down the problem that was causing the problem. I faithfully googled it and got the answer. In case you are facing the problem, here is what you need to do

1. Go to Tools –> Options

2. Under Content –> Choose Settings under AutoComplete

3. Check Web Address

That is it. No more crashes.

have fun.

Powered by WordPress