Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp2
  4. {
  5.     class Student
  6.     {
  7.         static void Main(string[] args)
  8.         { }
  9.         private string myName = "N/A";
  10.         private int myAge = 0;
  11.         public string Name
  12.         {
  13.             get
  14.             {
  15.                 return myName;
  16.             }
  17.             set
  18.             {
  19.                 myName = value;
  20.             }
  21.         }
  22.         public int Age
  23.         {
  24.             get
  25.             {
  26.                 return myAge;
  27.             }
  28.             set
  29.             {
  30.                 myAge = value;
  31.             }
  32.         }
  33.         public override string ToString()
  34.         {
  35.             return "Name = " + Name + ", Age = " + Age;
  36.         }
  37.         public static void Main()
  38.         {
  39.             Student Student = new Student();
  40.             Console.WriteLine("Student details - {0}",Student);
  41.             Student.Name = "BOB";
  42.             Student.Age = 99;
  43.         }
  44.         }
  45.    
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement