Ray's playground

 

C# Language Basics(Chapter 2 of C# 4.0 in a nutshell)

Optional Parameters
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 
 6 namespace ConsoleApplication
 7 {
 8     class Program
 9     {
10         static void Foo(int x, int y = 1
11         {
12             Console.WriteLine(x + "," + y);
13         }
14 
15         static void Main(string[] args)
16         {
17             var x = 5;
18             Foo(x);
19             Foo(x: 1, y: 2);
20             Foo(y: 2, x: 3);
21             Foo(4);
22             Console.Read();
23         }
24     }
25 }
26 

 

posted on 2010-05-22 22:52  Ray Z  阅读(204)  评论(0编辑  收藏  举报

导航