Advertisement
KodingKid

C# Properties

Mar 23rd, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.32 KB | None | 0 0
  1. class Humanoid
  2. {
  3.   private string username;
  4.   public string Username
  5.   {
  6.     get { return username; }  
  7.     set { username = value; }  
  8.   }
  9. }
  10. class Program
  11. {
  12.   static void Main(string[] args)
  13.       {
  14.     Humanoid myObj = new Humanoid();
  15.     myObj.Username = "Player1";
  16.     Console.WriteLine(myObj.Username);
  17.   }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement