|
An Example
This example implements a counter, which includes two forms. The form on the right shows the count. |
|
|
using System;
using System.Windows.Forms;
namespace WindowsFormsApp1 {
public partial class Form1 : Form {
public Form1( ) { InitializeComponent( ); }
private void Start_Click( object sender, EventArgs e ) {
double next;
double previous = DateTime.Now.TimeOfDay.TotalSeconds;
double finish = previous + int.Parse( sec.Text );
int i = 1;
Count f = new Count( );
do {
next = DateTime.Now.TimeOfDay.TotalSeconds;
if ( next - previous >= 1 ) {
f.Hide( );
f.display.Text = i.ToString( );
f.Show( );
i = i + 1;
previous = next;
}
} while ( finish > next );
}
}
}
|
Public keyword specifies that one or more declared programming elements have no access restrictions.
Private keyword specifies that one or more declared programming elements are accessible only from within their declaration context.
Class statement declares the name of a class and introduces the definition of the variables, properties, events, and procedures.