In below example, I am only showing two Hello World messages. In line no. 18 and 24, I have used two buttons to perform the task. First, I have displayed the Hello World message in a Label control of C#.Net and in second I have used MessageBox.Show method to display the Hello World message in a pop up tiny window. Just copy and past this code in your C# page and hit F5 to run the program. This program in only intended for Visual Studio 2005 and upgraded versions.
Hello World |
1: using System;
2: using System.Collections.Generic;
3: using System.ComponentModel;
4: using System.Data;
5: using System.Drawing;
6: using System.Text;
7: using System.Windows.Forms;
8:
9: namespace BlogWorld___HelloWorld
10: {
11: public partial class Form1 : Form
12: {
13: public Form1()
14: {
15: InitializeComponent();
16: }
17:
18: private void btnClickMe_Click(object sender, EventArgs e)
19: {
20: //To print a "Hello World" message on a Label
21: lblMsg.Text = "Hello World!";
22: }
23:
24: private void btnClickMsg_Click(object sender, EventArgs e)
25: {
26: //To print a "Hello World" message on Message Box
27: MessageBox.Show("Hello World!");
28: }
29: }
30: }
No comments:
Post a Comment