5
Answers

Property in C#

Ask a question
Arun Kurmi

Arun Kurmi

11y
984
1
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)