pause at 31minutes

This commit is contained in:
2026-01-11 23:13:26 +01:00
parent 67ef71092a
commit 0a1934f95a
5 changed files with 160 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
# Starting a project
The project inizialize automaticly inside visual studio
```C#

View File

@@ -0,0 +1,46 @@
# Output
## Console.Write
to output a message in the console you can run the method
using a string literal
```C#
Console.WriteLine("Hello");
```
## Console.Write
The same but doesn't add a line at the end of the sentece
```C#
Console.Write("Hello");
Console.Write("You");
// Output
// HelloYou
```
## Comments
```C#
///This is a comment
/* this is a
* multiline command
*/ comment
```
## Escape Sequence
```C#
// tab
Console.WriteLine("\tHello")
// backspace
Console.WriteLine("Hello\bWorld")
// newLine
Console.WriteLine("Hello\nWorld")
```
## Console.ReadKey();
Prevent our program to end until we type a key

View File

@@ -0,0 +1,84 @@
# Variables
## int
for storing integer
```c#
int age = 21;
```
## double
can store a decimal
```C#
double height = 300.5;
```
## bool
can store boolean
only true or false
```C#
bool alive = true;
```
## char
for a single carachter
```C#
char symbole = '@';
```
## String
don't forget the S in upper
```C#
String name = "Hello";
```
## constants
immutable values wich are known at compile time and
do not change for th life of the program
just add the const keyword
```C#
const double pi = 3.14;
```
## Type casting
Converting a value to a different data type
Very useful because user input will always be strings
```C#
double a = 3.14;
int b= Convert.ToInt32(a);
int c= 123;
double d= Convert.ToDouble(c);
int e= 321;
String d= Convert.ToString(e);
String g = "$";
char h = Convert.ToChar(g);
String i = "true";
bool j = Convert.ToBoolean(i);
```
## GetType
Get the type of a variable
```C#
double a = 3.14;
Console.WriteLine(a.GetType())
```

View File

@@ -0,0 +1,16 @@
# User input
## Console.ReadLine
```C#
Console.Write("Type your name : ");
String name = Console.ReadLine();
// Can cause an error if the user write another type than int
Console.Write("What's your age : ");
int age = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Hello " + name);
Console.WriteLine("you are " + age + " years old");
```