I am playing around with using properties and ran into a problem, its probably simple and i am over looking it, but what i want to do is when a person types in a textbox yes, the textbox is equal to pullfromclass.HavingFun which is a property that says if havingfun == yes (havingfun and Havingfun is different, but look at the code below to see if it makes sense or if that can be my problem) if yes then great, if not sorry to hear about that, but for some strange reason its not working again that could be the problem but please let me know if i am doing something wrong thanks:
the button object:
private void button1_Click(object sender, EventArgs e)
{
pullfromclass.Name = textBox3.Text;//from first class with property - pullfromclass.Name
MessageBox.Show(pullfromclass.test(pullfromclass.Name) + " " + pullfromclass.lastname);
//using inheritance to get a field from class2 from class1
pullfromclass.funstuff(textBox4.Text);
MessageBox.Show(pullfromclass.answer);
}
the class1:
private string havingfun;
public string answer;
public string Havingfun
{
get { return havingfun; }
set
{
if (havingfun.ToLower() == "yes")
{
answer = "Great that you are";
}
else
{
answer = "sorry to hear about that";
}
}
}
thanks in advance


Sign In
Create Account


Back to top









