April 19, 2010
@ 09:45 AM
Last week someone asked me about "yield" that he saw in my blog. It is very embarrassed me, I totally forget what it is.
I can't keep the "yield" in my mind because it is not something like "what you see is what it is". it even didn't has "return" in the code scope, that make code not easy to read.  that new feature of c#3.0 need me more time to familiar with.


But the new feature "Default Parameter" in c# 4.0 give me some different feeling ,
This is something very nature and  very easy to use.

private void TestFunction(string username,bool isAdmin=false)
{
    //do something..
}

/// since have Default Parameter, this overLoad function is no more need
//private void TestFunction(string username)
//{
//    TestFunction(username,false);
//}
public void Test()
{
     TestFunction("user");
     TestFunction("user1",true)

 
}


This will make you code cleaner and easier to read in many cases.