笔记006 重载是什么

重载,简单来说,就是函数或者方法有相同的名称,但是参数列表不相同的情形,这样的同名不同参数或者方法之间,互相称之为重载函数或者方法。

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Student Steven = new Student("99","FUPU","男",Convert.ToDateTime("2001-2-18"),"18965428945","FUPU@168.com","翻斗大街翻斗花园2号楼1001室");
            Student Steven1 = new Student("99", "FUPU", "男", Convert.ToDateTime("2001-2-18"), "18965428945", "FUPU@168.com");
            Student Steven2 = new Student("99", "FUPU", "男", Convert.ToDateTime("2001-2-18"), "18965428945");
            Student Steven3 = new Student("99", "FUPU", "男", Convert.ToDateTime("2001-2-18"));
            Student Steven4 = new Student("99", "FUPU", "男");
            Student Steven5 = new Student("99", "FUPU");
            Steven.SayHello();
                Console.ReadKey();
        }
        
    }
    class Student
    {
        //属性
       
        //学号
        public string SNO { get; set; }
        //姓名
         public string SName { get; set; }
        //性别
        public string Gender{ get; set; }
        //出生日期
       public DateTime Birthday { get; set; }
        //手机号码
        public string MObile { get; set; }
        //邮箱地址
         public string Email { get; set; }
        //家庭住址
       public string HomeAddress { get; set; }
        //方法
        public void SayHello()
        {
            Console.WriteLine("大家好,我的学号是:{0}叫做{1},是一个{2}生,于{3}出生,手机号为{4},邮箱地址为{5},家住{6}",
              SNO, SName, Gender, Birthday, MObile, Email, HomeAddress);
        }
        //构建方法:包含1个参数
        public Student(string sno)
        {
            SNO = sno;
        }
        //构建方法:包含2个参数
        public Student(string sno, string sname) : this(sno)
        {
            SName = sname;
        }
        //构建方法:包含3个参数
        public Student(string sno, string sname, string gender):this(sno,sname)
        {
            Gender = gender;
        }
        //构建方法:包含4个参数
        public Student(string sno, string sname, string gender, DateTime birthday):this(sno,sname,gender)
        {
            Birthday = birthday;
        }
        //构建方法:包含5个参数
        public Student(string sno, string sname, string gender, DateTime birthday, string mobile):this(sno,sname,gender,birthday)
        {
            MObile = mobile;
        }
        //构建方法:包含6个参数
        public Student(string sno, string sname, string gender, DateTime birthday, string mobile, string email) : this(sno, sname, gender, birthday,mobile)
        {
            Email = email;
        }
        //构建方法:包含7个参数
        public Student(string sno, string sname, string gender,DateTime birthday,string mobile,string email,string homeaddress) : this(sno, sname, gender, birthday, mobile,email)
        {
            HomeAddress = homeaddress;
        }
    }
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值