Home > Net >  Ask bosses, give advice or comments in c # the Convert. ToInt32 (txtHour. Text) of txtHour. The Text
Ask bosses, give advice or comments in c # the Convert. ToInt32 (txtHour. Text) of txtHour. The Text

Time:09-29


Using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
Using System. Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Using System. Windows. Forms;

The namespace _4_2
{
Public partial class Form1: Form
{
Public _click ()
{
InitializeComponent ();
}
The class Time
{
Private int hour;
Private int minute;
Private int second;
Public Time ()
{
Hour=System. A DateTime. Now. The hour;
Minute=System. A DateTime. Now. The minute;
Second=System. A DateTime. Now. The second;
}
Public Time (int h, int m, int s)
{
Hour=h; Minute=m; Second=s;
}
Public void AddSecond ()
{
Second++;
If (second & gt;=60)
{
Second=second % 60;
Minute++;
}
If (minute & gt;=60)
{
Minute=60 minute %;
Hour++;
}
}
Public int the adrenaline-charged
{
The get=& gt; Hour;
}
Public int Minute
{
The get=& gt; Minute;
}
Public int Second
{
The get=& gt; Second;
}
Private void button1_Click (object sender, EventArgs e)
{
Time Time=new Time (Convert ToInt32 (txtHour. Text), Convert the ToInt32 (txtMinute. Text), Convert the ToInt32 (txtSecond. Text);
Time. AddSecond ();
TxtHour. Text=the Convert. ToString (time. The Hour);
TxtMinute. Text=the Convert. ToString (time, Minute);
TxtSecond. Text=the Convert. ToString (time. Second);
}
}


Private void Form1_Load_1 (object sender, EventArgs e)
{
Time t1=new Time ();
TxtHour. Text=the Convert. ToString (t1) Hour);
TxtMinute. Text=the Convert. ToString (t1) Minute);
TxtSecond. Text=the Convert. ToString (t1. Second);
}
}
}

CodePudding user response:

TxtHour txtMinute etc., is a member of the Form1, not class members of the Time,

CodePudding user response:

You try to put the button1_Click event, how can you put the button1_Click Time class?
Structure it is good to:

CodePudding user response:

Time class out alone, so embedded call some confusion,

CodePudding user response:

TXT. Hour this space does not exist, your code is directly copied from other sources in the past
  • Related