• 深入.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

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

  • 相关阅读:
    js人工智能对话框
    html 实现相册
    thinkphp5 三种重定向(跳转)
    thinkphp5 分页实现
    常用的Mysql数据库操作语句大全
    FormData之file图片上传
    FormData对象
    input file 上传图片时限制格式
    form 中Enctype=multipart/form-data 的作用
    thinkphp5 不刷新退出
  • 原文地址:https://www.cnblogs.com/chenhui666/p/6676034.html
Copyright © 2020-2023  润新知