Issues with passing values to class C#
Time is the class i'm trying to pass the values to. (txtHour.Text, txtMin.Text) are the values. I'm just trying to pass the values to the parameterized constructor. And i'm not totally sure what t开发者_Go百科he syntax for that is.
Time time1;
time1 = (txtHour.Text, txtMin.Text);
** That method seems to work except for that i'm passing into int values and the values of the Text box are considered string it seems. And when i int parse them it says it's not the correct format to pass the value.
Time time1 = new Time(txtHour.Text, txtMin.Text);
Constructors in C# are (typically) called by using the new
keyword in combination with the class name (and any parameters in parenthesis similar to a method call):
Time time1 = new Time(txtHour.Text, txtMin.Text);
I would have thought you would have to convert?
Time time1 = new Time(
Convert.ToInt32(txtHour.Text.Trim()),
Convert.ToInt32(txtMin.Text.Trim()));
精彩评论