• 类的测试


    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace ConsoleApplication1
    {
      class myclass
        {
            private int intStudentId;//定义字段(私有成员)
            public int _intStudentId //定义属性
            {
                get { return intStudentId; }
                set
                {
                    if (value< 0)
                    {
                        intStudentId = -value;
                    }
                    else  intStudentId = value;
                }

            }
            public myclass(string strName)//带参数的构造函数
            {

                Console.Write(strName);
            }
            public myclass()//默认构造函数
            {
                Console.Write("Hello!");
           
           
            }
            public static string GetNation (string strNation)//公有的静态方法(通过类可以访问,不同实例化)

            {

                return strNation;
             }


         

        
        }

        class  TestClass
        {
            static void Main(string[] args)
            {

                Console.Write("My Nation is:" + myclass.GetNation("China"));
                Console.Write("\n");
                myclass annclass = new myclass();
                Console.Write("\n");
                myclass lzlClass = new myclass("lzl");
                Console.Write("\n");
                lzlClass._intStudentId = -100;
                Console.Write(lzlClass._intStudentId);
                Console.ReadLine();
            } 
        }

         


    }

  • 相关阅读:
    成功实施的APS项目故事分享---我们数据治理的心路历程
    成功实施的APS项目故事分享---如何管理与激励APS项目团队
    东莞裕同&易普优APS项目启动啦!
    包装印刷行业裕同集团&易普优APS项目顺利验收!
    易普优APS混流排序算法助力汽车整车厂的均衡生产
    动态调用WebService接口
    C#推送RocketMQ信息
    DEV带筛选行CheckBox选中问题
    验证上传文件真实格式
    PLSQL导出触发器代码
  • 原文地址:https://www.cnblogs.com/liuzhengliang/p/1311252.html
Copyright © 2020-2023  润新知