zoukankan      html  css  js  c++  java
  • 学会了调用方法

    创造了一个类,对象化,然后调用

    方法必须有一个返回值(int,string)或Void

    如 public int firstMethod()

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

    namespace test5
    {
        class Example
        {
            static void Main()
            {
              
                dgx gg = new dgx();
                int c = gg.firstMethod();
                Console.WriteLine(c);
                Console.Read();
                 
                          

                  
            }
            class dgx
            {
                public int firstMethod()
                {
                    int myField = 42; // ok
                    return myField;

                }

                public int anotherMethod()
                {
                    int myField = 52; // ok
                    return myField;

                }
            }

          
                  
        }
     
    }

  • 相关阅读:
    C++ 类 构造函数 constructor
    数据库——关系代数
    海明码
    C++ this指针
    C++ 类的定义与实现
    C++ 函数 内联函数
    C++ 函数 函数的重载 有默认参数的函数
    2017年第八届蓝桥杯【C++省赛B组】
    2018年第九届蓝桥杯【C++省赛B组】
    C++ 函数 参数传递方式
  • 原文地址:https://www.cnblogs.com/bluewelkin/p/1285114.html
Copyright © 2011-2022 走看看