TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
osyris zosar
NA
289
27.1k
error with Get and set
Dec 18 2020 5:21 PM
I am trying to figure out how Get and set works, and i am getting a error and i dont really understand why.
constructor with get and set
class
Accounts
{
public
string
Nameinfo;
public
int
Ageinfo;
public
Accounts(
string
aName,
int
aAge,
string
aprice)
{
Nameinfo = aName;
Ageinfo = aAge;
Price = aprice;
}
public
string
Price
{
get
{
return
Price; }
set
{
if
(value ==
"1"
|| value ==
"2"
)
{
Price = value;
MessageBox.Show(
"good"
);
}
else
{
value =
"0"
;
MessageBox.Show(
"not valid"
);
}
}
}
}
Button to activate the constructor
private
void
test_Click(
object
sender, RoutedEventArgs e)
{
Accounts accountss =
new
Accounts(
"jack"
, 2,
"1"
);
MessageBox.Show(accountss.Nameinfo);
accountss.Price = textbox.Text.ToString();
}
Reply
Answers (
2
)
How to improve debugging skill in stored procedures in SQL Server
C# image subtraction