美文网首页C语言
C#中所涉及的“封装”到底指什么,您真的知道吗?

C#中所涉及的“封装”到底指什么,您真的知道吗?

作者: 一位热爱文学的程序员 | 来源:发表于2019-08-04 08:19 被阅读0次

    1、属性封装

    private int _Age;

    public string Age{

    get{

    return _Age;

    }

    set{

    if(value>1000&&value<1200){

    _Age = value;

    }

    }

    -------------------------------------------------------------------

    2、函数传递参数进行封装

    func(string a,string b ,string c){

    funca(string a,string b ,string c){}

    }

    改造后=》

    class student{

    public string a;

    public string b;

    public string c;

    }

    Func(new student(){a=“1”,b=“2”,c=“3”});

    func(student student){

    funca(student student){

    }

    }

    -------------------------------------------------------------------

    3、右键重构可以提取到新的方法中去

    相关文章

      网友评论

        本文标题:C#中所涉及的“封装”到底指什么,您真的知道吗?

        本文链接:https://www.haomeiwen.com/subject/yzjedctx.html