How to use private property in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class CClass
    {
        int _score;
        private int Score
        {
            get
            {
                return _score;
            }
            set
            {
                _score = value;
            }
        }
        public void Display()
        {
            Score = 128;
            Console.WriteLine(Score);
        }
    }
    class Program
    {
        static void Main()
        {
            CClass CClass = new CClass();

            CClass.Display();
        }
    }
}


/*
run:
   
128
 
*/

 



answered Aug 22, 2018 by avibootz

Related questions

1 answer 186 views
1 answer 163 views
1 answer 183 views
183 views asked Mar 14, 2016 by avibootz
1 answer 151 views
1 answer 131 views
131 views asked Sep 9, 2020 by avibootz
1 answer 166 views
1 answer 160 views
...