pruthvi-dumpa-amcs

C#-1

Nov 19th, 2025
125
0
28 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. public class Example
  2. {
  3.     public class TestStatic
  4.     {
  5.         public static int TestValue;
  6.         public TestStatic()
  7.         {
  8.             if (TestValue == 0)
  9.             {
  10.                 TestValue = 10;
  11.             }
  12.             else
  13.             {
  14.                 TestValue += 5;          
  15.       }
  16.     }
  17.          public void Print()
  18.         {
  19.             Console.WriteLine("TestValue : " + TestValue);
  20.         }
  21.     }
  22.    public static void Main()
  23.     {
  24.         TestStatic t = new TestStatic();
  25.         t.Print();  
  26.         TestStatic t1 = new TestStatic();
  27.         t1.Print();
  28.         TestStatic t2 = new TestStatic();
  29.         t2.Print();
  30.     }
  31.  
  32.  
Advertisement
Add Comment
Please, Sign In to add comment