Copy & Paste functions does not work in Visual Studio 2010

by Victor 4. May 2010 23:33

The new Visual Studio 2010 is cool. It has lots of existing new features. But I have found out my cut and paste function doesn't work properly. Then I found this post. Someone in Microsoft said: " There is a known issue with symptoms like the ones you describe - text will occasionally fail to paste.  Although it's not exclusive to remote desktop, that does make it significantly more likely.  The underlying issue is being tracked by an internally-filed bug and we're working on a fix.  For now, the best course of action is just to try copy/paste again; changing settings shouldn't affect this bug......". This is unbelievable. Every developer must know how important cut/paste is. Then in Visual Studio 2010 - the one of the most important product release this year, this basic function doesn't work. Totally Unbelievable!!!

Tags:

Programming

Named argument in C# 4.0

by Victor 4. May 2010 23:16

Named argument is a new feature in C# 4.0. Using this feature you do not need to remember or to look up the order of parameters in the parameter lists of called methods. The parameter for each argument can be specified by parameter name. In this case documentation become really important. 
For example, a simple function that return the sum of two parameters can be called in the standard way by sending arguments for param1 and param2 by position, in the order defined by the function.

SimpleFunction(100, 50); 

If you do not remember the order of the parameters but you do know their names, you can send the arguments in either order, weight first or height first.

SimpleFunction(param1: 100, param1: 50);
SimpleFunction(param2: 50, param1: 100);

Named arguments also improve the readability of your code by identifying what each argument represents. But it doesn't mean your documentation become unnecessary. 
Also A named argument can follow positional arguments (which are not specified by parameter name), like:

SimpleFunction(100, param2: 50);

In this case you cannot change the order of the arguments. However, a positional argument cannot follow a named argument. Even you follow the current argument order.  The following statement causes a compile time error (Named argument specifications must appear after all fixed arguments have been specified).

SimpleFunction(param1 : 100, 50);

Full Code Example

namespace ConsoleApplication1
{
  class Program
  {

    static void Main(string[] args)

    {
      Console.WriteLine(SimpleFunction(100, 50));//Successful
      Console.WriteLine(SimpleFunction(param1: 100, param2: 50));//Successful
      Console.WriteLine(SimpleFunction(param2: 50, param1: 100));//Successful
      Console.WriteLine(SimpleFunction(100, param2: 50));//Successful
      Console.WriteLine(SimpleFunction(param1: 100, 50));//Error
    }

    static int SimpleFunction(int param1, int param2)
    {
      return param1 + param2;
    }
  }
}


Tags:

Programming

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

Month List