OOP Terminology: class, attribute, property, field, data member

前端 未结 7 819
有刺的猬
有刺的猬 2020-12-05 04:49

I am starting studying OOP and I want to learn what constitutes a class. I am a little confused at how loosely some core elements are being used and thus adding to my confus

7条回答
  •  不知归路
    2020-12-05 05:10

    In The Class

    public class ClassSample
    {
        private int ClassAttribute;
    
        public int Property
        {
            get { return ClassAttribute; }
            set { ClassAttribute = value; }
        }
    }
    

    In the Program

        class Program
        {
            static void Main(string[] args)
            {
                var objectSample = new ClassSample();
                //Get Object Property
                var GetProperty = objectSample.Property;
            }
        }
    

提交回复
热议问题