首页 > Windows开发 > 详细

深入.NET平台和C#编程.第四章:深入类的方法.简答题5---陈辉

时间:2017-04-07 01:06:15      阅读:818      评论:0      收藏:0      [点我收藏+]

------------------------------------------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 }
View Code

------------------------------------------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 }
View Code

------------------------------------------运行结果----------------------------------------------

技术分享

深入.NET平台和C#编程.第四章:深入类的方法.简答题5---陈辉

原文:http://www.cnblogs.com/chenhui666/p/6676034.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!