-
-
Notifications
You must be signed in to change notification settings - Fork 117
C# #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
C# #2
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| class BREAK | ||
| { | ||
| public BREAK() | ||
| { | ||
| const bool flag = true; | ||
| Console.WriteLine("Hello"); | ||
| if (flag) break; | ||
| Console.WriteLine("World"); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| class BREAK | ||
| { | ||
| public BREAK() | ||
| { | ||
| const bool flag = true; | ||
| Console.WriteLine("Hello"); | ||
| if (flag) continue; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| Console.WriteLine("World"); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| class WHILE | ||
| { | ||
| public WHILE() | ||
| { | ||
| int i = 0; | ||
| do | ||
| { | ||
| Console.WriteLine(i++); | ||
| } while (i < 10); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| class FOR | ||
| { | ||
| public FOR() | ||
| { | ||
| for (let i = 0; i < 10; i++) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| { | ||
| Console.WriteLine(log(i)); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| class FOREACH | ||
| { | ||
| public FOREACH() | ||
| { | ||
| const int a = { 7, 10, 1, 5, 2 }; | ||
| foreach (int i in b) | ||
| Console.WriteLine(i); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| class GOTO | ||
| { | ||
| public GOTO() | ||
| { | ||
| Console.WriteLine("Coffee sizes: 1=Small 2=Medium 3=Large"); | ||
| Console.Write("Please enter your selection: "); | ||
| string s = Console.ReadLine(); | ||
| int n = int.Parse(s); | ||
| int cost = 0; | ||
| switch (n) | ||
| { | ||
| case 1: | ||
| cost += 25; | ||
| break; | ||
| case 2: | ||
| cost += 25; | ||
| goto case 1; | ||
| case 3: | ||
| cost += 50; | ||
| goto case 1; | ||
| default: | ||
| Console.WriteLine("Invalid selection."); | ||
| break; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| class WHILE | ||
| { | ||
| public WHILE() | ||
| { | ||
| int a = 0; | ||
| while (a < 10) | ||
| { | ||
| Console.WriteLine(a++); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
breakmust be used inside the loop, otherwise it won't compile and don't make sense.