20180309 - C# demo - 1

 1 using System;
 2 namespace HelloWorldApplication
 3 {
 4     class HelloWorld
 5     {
 6         static void Main(string[] args)
 7         {
 8             // 1
 9             Console.WriteLine("Hello C# World!");
10             Console.WriteLine("A:{0}, B:{1}", 10, 20);
11             Console.WriteLine("A:{1}, B:{0}", 10, 20);
12             Console.WriteLine("A:{0}, B:", 10, 20);
13             Console.WriteLine("A:{1}, B:", 10, 20);
14             Console.WriteLine("A:, B:", 10, 20);
15             // 2
16             String str1 = "C:\\User";
17             String str2 = @"C:\User";
18             String str = @"
19             Hello C# World!
20     C# ------        very strong language.
21             ";
22             Console.WriteLine(str1);
23             Console.WriteLine(str2);
24             Console.WriteLine("{1}{0}{1}", str,"/");
25             //3
26             int val = 123;
27             Object box = val;
28             int valx = (int)box;
29             Console.WriteLine(box);
30             Console.WriteLine(val);
31             Console.WriteLine(valx);
32             //4
33             int a = 9;
34             Object obj;
35             obj = a;
36             obj = 10;
37             Console.WriteLine("a: {0}", a);
38             Console.WriteLine("obj: {0}", obj);
39             //string
40             string xStr = "Hello C#";
41             Console.WriteLine(xStr);
42             Console.ReadKey();
43         }
44     }
45 }

 

posted @ 2018-03-09 17:58  coder211  阅读(105)  评论(0编辑  收藏  举报