Introduction to C#

How to start a new project

From the main menu click on New Project and then give a name to your project, for example the default, WpfApp1, and then click Ok or press Enter. The following screen opens up to start the newly created application.
Created Application

A Visual C# application project starts with creating its GUI with Designer, Toolbox, and Property window. In the Designer, an empty form is automatically created where:

The rules for naming controls are illustrated here
Naming Controls

Introduction to C# programming

GUI applications are event-driven which means they interact with users. An event is a user's action including mouse clicking and key pressing.

Double clicking a control, such as Button, will link the control to a default Event Handler

C# code, a file that contains program code is called a source code file, is organized in three ways:

Each time a new project is created the following two source code files are automatically created
New Project

Organization of Form1.cs:

  1. The using directives indicate which namespaces of .NET Framework this will use.
    NET Framework
  2. The user-defined namespace of the project not .NET Framework namespaces
    Namespace in Python
  3. Class declaration and a method

Basically, C# code is organized as methods, which are contained inside classes, which are contained inside namespaces

By adding the following bold line to a Button's event handler, a Label control can display output of the application.
private void showAnswerButton_Click(object sender, EventArgs e)
{
answerLabel.Text = "Abraham Lincoln";
}
The Text property accepts string only and to clear the text of a Label, the following code can be used: answerLabel.Text = ""