Advertisement
idroj07

c#Console_ClassmethodError

Aug 20th, 2019
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement