How to use public fields in class with c#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Test
    {
        public int _n;

        public void Show()
        {
            Console.WriteLine(_n);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Test t = new Test();

            t._n = 1000;

            t.Show();
        }
    }
}


/*
run:
 
1000

*/

 



answered Jan 1, 2017 by avibootz

Related questions

1 answer 146 views
2 answers 143 views
143 views asked Dec 6, 2023 by avibootz
1 answer 190 views
1 answer 112 views
112 views asked Sep 9, 2020 by avibootz
...