Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace StaticMethodInConstructor
- {
- using System;
- class Program
- {
- static void Main(string[] args)
- {
- TestStaticMethodInClass testStaticMethodInClass = new TestStaticMethodInClass(-1);
- Console.WriteLine(testStaticMethodInClass.ClassTestNumber);
- }
- }
- public class TestStaticMethodInClass
- {
- private int classTestNumber;
- public int ClassTestNumber
- {
- get { return classTestNumber; }
- set { classTestNumber = value; }
- }
- public TestStaticMethodInClass(int number)
- {
- this.classTestNumber = ValidateNumber(number);
- }
- public static int ValidateNumber(int number)
- {
- if (number > 0)
- {
- return number;
- }
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement