Advertisement
damesova

FormattingExample1

Mar 19th, 2023
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | Source Code | 0 0
  1. namespace MyNamespace
  2. {
  3.  
  4.     public class MyClass
  5.     {
  6.         private int myField;
  7.  
  8.         public int MyProperty
  9.         {
  10.             get
  11.             {
  12.                 return this.myField;
  13.             }
  14.  
  15.             set
  16.             {
  17.                 if (value < 0)
  18.                 {
  19.                     throw new ArgumentOutOfRangeException("value", "MyProperty must be non-negative");
  20.                 }
  21.  
  22.                 this.myField = value;
  23.             }
  24.         }
  25.  
  26.         public void MyMethod(int myParameter)
  27.         {
  28.             if (myParameter > 0)
  29.             {
  30.                 Console.WriteLine("MyParameter is positive");
  31.             }
  32.             else
  33.             {
  34.                 Console.WriteLine("MyParameter is zero or negative");
  35.             }
  36.         }
  37.     }
  38. }
  39.  
Tags: formatting
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement