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

------------------------------------------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

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

转载于:https://www.cnblogs.com/chenhui666/p/6676034.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值