An easy and light way to learn C# Language

• In the name of Allaah (God Almighty)

• Peace be upon you...

• If Allaah wills

~ Now we will learn about Write, Run or Execute Codes and Print or Output your first C# code on a Console Application.

11. How to Write and Run your first C# code on a Console Application and What is a Print or an Output?

• To write your first code, open the online compiler or a Console Application on Visual Studio Code. For the online compiler, follow the link below:

Link: https://onecompiler.com/csharp

• Now change the red words "Hello, World!" to your own words, like I can write "in the name of Allah". Remember, it always remains between the double quotation marks (" "). This is called a string and don't forget to put the double quotation marks.

• Now click the RUN button to Execute your first code. You will see a Print or an Output. ( a Print or an Output is a result of an Input after Executing a program .)

~ For example, the output will be: in the name of Allah (without double quotation marks).

• Congratulations, you have learned to write and run your first C# code.

* Note: To print or execute a C# code on a Console Application, the syntax used is WriteLine: i.e.,

Console.WriteLine("Here the words you want to print");

• Keep practicing with many lines of syntax with different words.

• Lesson- 8, About Write, Run or Execute Codes, Print or Output

~ Now we will learn about the most common data types.

12. What is a data type and what are their functions?

• A data type, also known as a variable, is a temporary data holder that stores data according to its ability in the application to display or perform various operations.

• There are many data types available in C#, but we will focus on the common data types mostly used in applications.

~ Let's introduce some of these variables:

1) string represents Text data type (e.g., "myText").

2) int represents Integer number data type (e.g., 1, 2, -3).

3) float represents Floating point number data type (e.g., 1.5, -2.50).

4) bool represents a Boolean value to check whether a condition is true or false.

* Note: All variable names start with a lowercase letter; avoid using capital letters, as it will change the condition.

• Later, if Allah wills, we will discuss more about other variables and their details.

• Lesson- 9, About Data Types or Variables

Now, we will learn more details about the string data type.

13. What is a string variable and how to use it?

• A string is a variable that holds (or stores) data or value assigned in double quotation marks ("Here"). It cannot perform calculations, even if we input numbers into it, such as 1, 2, 3, etc. For example:

• As we have learned in our previous lesson, to print a text in the console application, we use the WriteLine syntax with Console. The code will be:

Console.WriteLine("Your Text");

• To use a string variable, the formula will be as follows:

a) To initialize the structure should be: variable name = "Value or value"

~ First, specify 'string', then the name of the string, followed by the value "Your Text". At the end of every statement of codes, a semicolon ";" is required. So the code will be:

// Copy the code from below and paste it into the compiler to test the result:

string textValue = "Your Text"; // <--- Start

// b) To declare this, we need to write the following syntax:

Console.WriteLine(textValue); // ---> End

• The output will be: Your Text.

* Note: C# language is case-sensitive, for example, 'String' and 'string', or "Your Text" and "your Text" have different meanings.

• Congratulations! Now we have finished learning about the 'string' data type, in sha Allah, in the next lesson, we will learn about the 'integer' variable, and today's task will be to practice more with different names and multiple outputs."

• Lesson- 10, About 'string'

~ Now we will learn details about the integer data type.

14. What is an integer variable and how is it used?

• An integer, represented as 'int', is a variable that stores positive and negative numbers only, for example, 1, 2, 3 or -1, -2, -3. Unlike a string, it doesn't accept letters and double quotation marks (" ").

• Its storage capacity is 32 bits, which means 4 bytes and it can accommodate approximately 4 billion positive and negative value of numbers. It can perform calculations using operators such as +, -, *, /, etc. We will discuss more about the operators later.

~ Example of an integer:

Console.WriteLine(100); Output: 100

Here, 100 is an integer.

• To use the 'int' variable, we first need to initialize the value, for example,

// Copy the code from below and paste it into the compiler to test the result:

int nameOfInt = 100; // <--- Start

// • Then we have to declare the value using:

Console.WriteLine(nameOfInt); // ---> End

The output will be: 100

~ Congratulations! We have now completed learning about the 'int' data type, In sha Allah. In the next lesson, we will learn about the 'float' variable, and the task will be to practice more with different numbers and multiple outputs.

• Lesson- 11, About 'integer'

~ Now we will learn more details about the 'floating' data type.

15. What is a 'float' variable, and how is it used?

• A 'float' is a variable that stores floating point numbers, such as 1.2, 2.30, or -3.543 and similar to an 'integer' that, it doesn't accept letters and double quotation marks (" ").

• It has a storage capacity of 32 bits, which equals 4 bytes. It can accommodate 7 to 9 digits of positive and negative values. It can perform calculations using operators such as +, -, *, /, etc. We will discuss more about the operators later.

~ Example of a float:

Console.WriteLine(10.5f); Output: 10.5

Here, 10.5f is a float.

* Note: The 'f' at the end of the number defines it as a float.

• To use the 'float' variable, we first need to initialize the value, for example:

// Copy the code from below and paste it into the compiler to test the result:

float nameOfFloat = 20.34f; // <--- Start

// • Then we have to declare the value using:

Console.WriteLine(nameOfFloat); // ---> End

The output will be: 20.34

~ Congratulations! We have now completed learning about the 'float' data type. In sha Allah, in the next lesson, we will learn about the 'Boolean' variable, and Today's task will involve practicing with different floating numbers and multiple outputs.

• Lesson- 12, About 'floating'

~ Now we will learn more details about the 'boolean' data type.

16. What is a 'boolean' variable, and how is it used?

• A boolean, represented as 'bool', is a variable that only checks the condition whether it is true or false. It doesn't accept double quotation marks (" ").

• To use the 'bool' variable, we first need to initialize the value, for example:

// Copy the code from below and paste it into the compiler to test the result:

bool nameOfBool = true; // <--- Start

// • Then we have to declare the value using:

Console.WriteLine(nameOfBool); // ---> End

The output will be: True

// Or

bool nameOfBool = false; // <--- Start

Console.WriteLine(nameOfBool); // ---> End

The output will be: False

~ Congratulations! We have now completed learning about the 'bool' data type. In sha Allah, in the next lesson, we will learn about the 'comments & operators',

• Lesson- 13, About 'boolean'