------------------------------------------SoClass类--------------------------------------------

1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace Sorcerer 8 { 9 public class SoClass 10 { 11 public int Jb { get; set; } 12 public int Zdl { get; set; } 13 public int Smz { get; set; } 14 15 public SoClass(int smz) 16 { 17 this.Smz = smz; 18 Console.WriteLine("巫师的生命值为:" + smz); 19 } 20 21 public SoClass(int jb, int zdl,int smz) 22 { 23 this.Jb = jb; 24 this.Zdl = zdl; 25 this.Smz = smz; 26 27 Console.WriteLine("巫师级别为:{0},战斗力为:{1},生命值为:{2}",jb , zdl , smz); 28 } 29 30 } 31 }
------------------------------------------Main()方法--------------------------------------------

1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace Sorcerer 8 { 9 class Program 10 { 11 static void Main(string[] args) 12 { 13 SoClass sc = new SoClass(10000); 14 15 SoClass scl = new SoClass(6666 , 8888 , 10000); 16 17 Console.ReadLine(); 18 } 19 } 20 }
------------------------------------------运行结果----------------------------------------------