若要在i<100這行設中斷點,可以將游標停留在此行,按f9,如:>
2009年6月22日 星期一
Tips: Visual Studio 設定除錯中斷點 1
若要在i<100這行設中斷點,可以將游標停留在此行,按f9,如:>
2009年6月18日 星期四
C# 4 Covariant & Contravariant
1 class outputsafe
2 {
3 static void Main(string[] args)
4 {
5 IEnumerable<string> data = new string[] { "a", "b" };
6 PrintData(data);
7 }
8 public static void PrintData(IEnumerable<object> o)
9 {
10 foreach (var t in o)
11 {
12 Console.WriteLine(t);
13 }
14 }
15 }
2009年6月17日 星期三
VB 10 的新語法
1 Module Module1
2 Property EmpName As String = "Mary"
3 Sub Main()
4 Console.WriteLine(EmpName)
5 End Sub
6 End Module
2.Collection Initializers & Statement Lambdas ,
除了3.5的Array Initializer之外,多了Collection Initializers
1 Module Module1
2 Sub Main()
3 '陣列初始設定式
4 Dim dataArr() As Integer = {1, 4, 23, 21, 34, 24}
5 Array.ForEach(dataArr, Sub(x)
6 Console.WriteLine(x)
7 End Sub)
8
9 '集合初始設定式
10 Dim dataCol As New List(Of Integer) From {1, 4, 23, 21, 34, 24}
11 dataCol.ForEach(Sub(x)
12 Console.WriteLine(x)
13 End Sub)
14 End Sub
15 End Module
C# 4 具名參數
1 class Program
2 {
3 static void Main(string[] args) {
4 Console.WriteLine(Add(x:20,y:10));
5 }
6 static int Add(int x, int y)
7 {
8 return x + y;
9 }
10 }
C# 4 選擇性引數(Optional Arguments)
1 class Program {
2 static void Main(string[] args) {
3 Console.WriteLine(Add(10, 20));
4 Console.WriteLine(Add(10, 20,30));
5 }
6 static int Add(int x, int y, int z = 0) {
7 return x + y + z;
8 }
9 }