标签:
1 class Program 2 { 3 static void Main(string[] args) 4 { 5 int x = 0; 6 Program p = new Program(); 7 p.ChangeValue(x, p); 8 Console.WriteLine("x=" + x + ",p.count=" + p.count); 9 Console.ReadLine(); 10 11 12 } 13 public void ChangeValue(int pValue,Program p) 14 { 15 int temp = pValue; 16 pValue = 10; 17 p.number = 10; 18 p.count = 10; 19 p = new Program(); 20 p.count = 20; 21 22 } 23 public int number = 0; 24 public int count = 0; 25 }
1 class Program 2 { 3 static void Main(string[] args) 4 { 5 int x = 0; 6 Program p = new Program(); 7 p.ChangeValue(ref x, ref p); 8 Console.WriteLine("x=" + x + ",p.count=" + p.count); 9 Console.ReadLine(); 10 11 12 } 13 public void ChangeValue(ref int pValue,ref Program p) 14 { 15 int temp = pValue; 16 pValue = 10; 17 p.number = 10; 18 p.count = 10; 19 p = new Program(); 20 p.count = 20; 21 22 } 23 public int number = 0; 24 public int count = 0; 25 }
1 class Program 2 { 3 static void Main(string[] args) 4 { 5 string fullName; 6 fullName = Combine(Directory.GetCurrentDirectory(), "bin", "config", "index.html"); 7 Console.WriteLine(fullName); 8 fullName = Combine(new string[] { Directory.GetCurrentDirectory(), "bin", "config", "index.html" }); 9 Console.WriteLine(fullName); 10 Console.ReadLine(); 11 } 12 static string Combine(params string[] paths) 13 { 14 string result = string.Empty; 15 foreach (string path in paths) 16 { 17 result = System.IO.Path.Combine(result, path); 18 } 19 return result; 20 } 21 22 }
1 class Program 2 { 3 static void Main(string[] args) 4 { 5 string firstName = "aaaaa", middleName = "bbbbbbbbb", lastName = "cccccccc"; 6 string fullName; 7 fullName = Combine(firstName); 8 Console.WriteLine(fullName); 9 10 fullName = Combine(pfirstName: firstName,plastName:lastName); 11 Console.WriteLine(fullName); 12 13 fullName = Combine(pfirstName: firstName, pmiddleName: middleName); 14 Console.WriteLine(fullName); 15 16 Console.ReadLine(); 17 18 19 } 20 static string Combine(string pfirstName, string pmiddleName = ".", string plastName = "") 21 { 22 string result = pfirstName + pmiddleName + plastName; 23 24 return result; 25 } 26 27 }
标签:
原文地址:http://www.cnblogs.com/tlxxm/p/4604517.html