forked from jmmortega/CSharpCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
91 lines (70 loc) · 2.2 KB
/
Copy pathProgram.cs
File metadata and controls
91 lines (70 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSharpCourse.BasicClauses
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please select a action");
int option = -1;
do
{
Console.WriteLine("1 - If statement");
Console.WriteLine("2 - For statement");
Console.WriteLine("3 - For each statement");
Console.WriteLine("0 Exit");
ConsoleKeyInfo keyInfo = Console.ReadKey();
option = int.Parse(keyInfo.KeyChar.ToString());
Console.Clear();
switch (option)
{
case 1:
IfStatement();
break;
case 2:
ForStatement();
break;
case 3:
ForEachStatement();
break;
}
} while (option != 0);
}
private static void IfStatement()
{
//This is a If statement. If you see is the same like C or Java
int value = 2;
int value2 = 3;
if(value == value2)
{
Console.WriteLine("Value is the same");
}
if(value.Equals(value2))
{
Console.WriteLine("Value is the same");
}
//'Equals' and '==' works in the same way
}
private static void ForStatement()
{
//Remember? This is a for statement
for(int i = 0 ; i < 10; i++)
{
Console.WriteLine("Look mom, I do a For!");
}
}
private static void ForEachStatement()
{
int[] arrayOfInt = new int[] { 2, 3, 4, 5, 6 };
//ForEach statement allow iterate any Collection.
foreach(int item in arrayOfInt)
{
Console.WriteLine(item);
}
}
}
}