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
Loading
VulpesPosted Apr 1, 2013, 3:10 PM
using System.Windows.Forms;
If it's a console application, you'll need to add a reference to System.Windows.Forms.dll as well as adding the above 'using' directive.
Jignesh TrivediPosted Apr 1, 2013, 11:52 PM
agree with Vuples
public int dummy
{
get
{
return 0;
}
set
{
System.Windows.Forms.MessageBox.Show("set Property");
}
}
hope this will help you.
Arun KurmiPosted Apr 1, 2013, 2:01 PM
Satyapriya NayakPosted Apr 1, 2013, 12:26 AM
Jignesh TrivediPosted Mar 31, 2013, 11:49 PM
1) yes, you can put message box in set block.
2) you are getting error on code stu.name="some one not arun"; right?
this is due to name is private member of class. .NET does not allow you to access private member out side of scope. so you got the error.
hope this will help you.