SHARE
TWEET

c#Console_ClassmethodError

idroj07 Aug 20th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace test //c# in console
  4. {
  5.     class TestClass
  6.     {
  7.         //members
  8.         private int mCod;
  9.  
  10.         //properties
  11.         public int Cod
  12.         {
  13.             get{
  14.                 return mCod;
  15.             }
  16.             set{
  17.                 mCod = value;
  18.             }
  19.         }
  20.         //methods
  21.         public void greetings()
  22.         {
  23.             Console.WriteLine("Hello!");
  24.         }
  25.     }
  26.     class Program
  27.     {
  28.         static void Main(string[] args)
  29.         {
  30.             TestClass testC = new TestClass();
  31.  
  32.             void functest() //U can't declare with privacy and outside Main
  33.             {
  34.                 Console.WriteLine("main func test");
  35.             }
  36.             bool i = true;
  37.  
  38.             if(i)
  39.                 Console.WriteLine("Hello World");                
  40.             functest();
  41.  
  42.             //using methods and properties of an internal class
  43.             testC.Cod = 3;
  44.             Console.WriteLine(testC.Cod + "\n");
  45.             testC.greetings;
  46.  
  47.         }
  48.     }
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top