problem with properties

Jan 16 2009 11:18 PM
hii all i have a problem in  using properties can u plzz lemme know where has my code gone wrong
this is my class
 class Class1
    {
        private int maths;
        private int science;
        private int social;
        private float total;
        private float percentage;
        //private float div;

        private void sum()
        {
            total = maths + science + social;
            percentage = total / 300;
        }
        public float MyProperty
        {
            get {
                return percentage ;
            }
        
           
        }

        public int mathspro { get { return maths;} set {maths = value ;} }
        public int sciencepro { get { return science; } set { science = value; } }
        public int socialpro { get { return social; } set { social = value; } }

    }
}

namespace csharpconstruct
{
    class Program
    {
        static void Main(string[] args)
        {
            float mess;

            Class1 clas = new Class1 ();
            clas.mathspro = 70;
            clas.sciencepro = 90;
            clas.socialpro = 90;
            mess = clas.MyProperty;
            Console.WriteLine(mess);
        }
    }
}




Answers (3)