-
-
Notifications
You must be signed in to change notification settings - Fork 120
Added C# examples #5
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
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,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Breeak | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
const bool flag = true; | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
Console.WriteLine("Hello"); | ||
if (flag) | ||
{ | ||
break; | ||
} | ||
Console.WriteLine("World"); | ||
} | ||
Console.WriteLine("There"); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Cont | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
int i = 0; | ||
while (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. Add indentation |
||
Console.WriteLine("Hello"); | ||
if (i == 5) continue; | ||
Console.WriteLine("Word"); | ||
} | ||
Console.ReadLine(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace doWhile | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
int i = 0; | ||
do | ||
{ | ||
Console.WriteLine(i++); | ||
} while (i < 10); | ||
Console.ReadLine(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace foor | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
Console.WriteLine(i); | ||
} | ||
Console.ReadLine(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace forEaach | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
int[] a = new int[] { 7, 10, 1, 5, 2 }; | ||
int i = 0; | ||
foreach (int item in a) | ||
{ | ||
Console.WriteLine("{0} {1} {2}", i, GetStringArray(a), item); | ||
i++; | ||
} | ||
Console.ReadLine(); | ||
} | ||
private static string GetStringArray(int[] array) | ||
{ | ||
string result = "[ "; | ||
for (int i = 0; i < array.Length; i++) | ||
{ | ||
result += array[i]; | ||
if (i != array.Length - 1) | ||
result += ", "; | ||
} | ||
result += " ]"; | ||
return result; | ||
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. return $"[ {String.Join(", ", array.Select(o => o.ToString()) )} ]"; 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. Or simply |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace whiile | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
int a = 0; | ||
while (a < 10) | ||
{ | ||
Console.WriteLine(a++); | ||
} | ||
Console.ReadLine(); | ||
} | ||
} | ||
} |
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.
To single line