zoukankan      html  css  js  c++  java
  • 类的测试

    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();
            } 
        }

         


    }

  • 相关阅读:
    Linux企业级项目实践之网络爬虫(12)——处理HTTP应答头
    Linux企业级项目实践之网络爬虫(11)——处理http请求头
    Linux企业级项目实践之网络爬虫(10)——处理HTTP状态码
    求区间最大子段和(线段树)
    求区间最大子段和(线段树)
    琐碎的知识点(xly)
    无源汇有上下界可行流(网络流进阶)
    bzoj2463谁能赢呢?
    bzoj2463谁能赢呢?
    日常(崩溃的边缘)
  • 原文地址:https://www.cnblogs.com/liuzhengliang/p/1311252.html
Copyright © 2011-2022 走看看