Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

Sunday, 27 September 2009

Get current date and time using C#

In this example, the date and time will be written to 'label1' when 'button3' is pressed.
private void button3_Click(object sender, EventArgs e)

{

label1.Text = DateTime.Now.ToString();

}

C# application that counts the number of characters being entered

This application consists of a textbox and a label. As the user types in the text box the label displays the number of characters that have been entered. The code is as follows :

private void textBox1_TextChanged (object sender, EventArgs e)

{
int charactercount;
string labeloutput;

charactercount = textBox1.TextLength;
labeloutput = charactercount.ToString();

lblcount.Text = "Character count : " + labeloutput;

{