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 188 views
1 answer 167 views
1 answer 186 views
186 views asked Mar 14, 2016 by avibootz
1 answer 156 views
1 answer 135 views
135 views asked Sep 9, 2020 by avibootz
1 answer 168 views
1 answer 164 views
...