Arun Kurmi

Arun Kurmi

  • NA
  • 104
  • 101.8k

Property in C#

Mar 31 2013 3:33 PM
hi friends,
(1) Is Possible use a messageBox to display a message in get{} or set{} Block ?I want to display a messege on the basis of value of set{} block.

My (2)Question are Commented in below code:

class Student
{
  private string name;
 
 public string Property
   {
      get
       {
            return name;
       }
       set
       {
            name=value;
       }
   }
}
------------------------------------------------
On button

Student stu=new Student();
stu.Property="arun";
string x=stu.Property;
//What is the meaning of below line.
stu.name="some one not arun"; //error

Answers (5)