C#之windows桌面软件第十三课:C#中常用的类有哪些?构造函数怎么用?

C#之windows桌面软件第十三课:C#中常用的类有哪些?构造函数怎么用?

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

/*object类*/

/*TextBox文本控件类*/
/*Button按钮类*/
/*CheckBox多选框类*/
/*Form窗体类*/
/*label标签控件类*/
/*GroupBox分组类*/
/*ProgressBar进度条类*/
/*SerialPort串口类*/
/*Timer定时器类*/
/*MessageBox提示框类*/
/*string字符串类*/
/*Convert类型转换类*/
/*Console输入输出流类*/
/*Exception系统异常类*/
/*SystemSounds系统提示音类*/
/*Image图像类*/
/*Bitmap位图类*/
/*Process进程类*/
/*Thread线程类*/

class Test
{
    public string str;

    //构造函数1
    public Test()
    {
        
    }
    //构造函数2
    public Test(string Init)
    {
        str = Init;
    }
    
}
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            //Test t = new Test("aaa");
            //构造函数1
            Test t1 = new Test();
            Test t2 = new Test();
            t1.str = "aaa";
            t2.str = "bbb";
            Console.WriteLine(t1.str+ "  " + t2.str);

            //构造函数2
            string str = "1";         //赋值方式1
            Test t3 = new Test(str);
            Console.WriteLine(t3.str);

            Test t4 = new Test("ccc");//赋值方式2
            Console.WriteLine(t4.str);


            Console.ReadLine();
        }
    }
}

www.DoYoung.net(部分代码来至杜洋工作室)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

魏波.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值