zoukankan      html  css  js  c++  java
  • C#构造方法--实例化类时初始化的方法

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                a a1 = new a();
    
                Console.ReadKey();
            }
        }
        class a
        {
            public a()//定义一个构造方法
            {
                Console.Write("1");
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                a a1 = new a("1");
    
                Console.ReadKey();
            }
        }
        class a
        {
            public a(string str)//定义一个构造方法
            {
                Console.Write(str);
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                a a1 = new a("1");
    
                Console.ReadKey();
            }
        }
        class a
        {
            /*
            public a()//如果自己不写那么默认这个
            { 
                
            }
            */
            public a(string str)//定义一个构造方法
            {
                Console.Write(str);
            }
        }
    }

  • 相关阅读:
    Oracle删除用户和表空间
    PLSQL配置教程
    Oracle 11g client 安装
    oracle 11g 安装
    oracle创建用户空间、导出、导入dmp备份文件方法
    c#关键字
    c#运算符重载
    每天一个Linux命令之date
    linux之2>&1
    每天一个Linux命令之crontab
  • 原文地址:https://www.cnblogs.com/yangfengwu/p/5864625.html
Copyright © 2011-2022 走看看