Advertisement
g-stoyanov

TestStaticMethodInClass

Feb 3rd, 2015
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. namespace StaticMethodInConstructor
  2. {
  3.     using System;
  4.  
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             TestStaticMethodInClass testStaticMethodInClass = new TestStaticMethodInClass(-1);
  10.             Console.WriteLine(testStaticMethodInClass.ClassTestNumber);
  11.         }
  12.     }
  13.  
  14.     public class TestStaticMethodInClass
  15.     {
  16.         private int classTestNumber;
  17.  
  18.         public int ClassTestNumber
  19.         {
  20.             get { return classTestNumber; }
  21.             set { classTestNumber = value; }
  22.         }
  23.  
  24.  
  25.         public TestStaticMethodInClass(int number)
  26.         {
  27.             this.classTestNumber = ValidateNumber(number);
  28.         }
  29.  
  30.         public static int ValidateNumber(int number)
  31.         {
  32.             if (number > 0)
  33.             {
  34.                 return number;
  35.             }
  36.  
  37.             return 0;
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement