-
Notifications
You must be signed in to change notification settings - Fork 36
/
csharp.cs
48 lines (42 loc) · 1.25 KB
/
csharp.cs
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
// A Hello World! program in C#.
using System;
using System.Collections.Generic;
namespace HelloWorld
{
internal class Program
{
/// <summary>
/// Entry Point to Program
/// </summary>
/// <param name="args"></param>
private static void Main(string[] args)
{
Console.WriteLine("Hello World!");
static IEnumerable<int> GetOddSequenceEnumerator(int end)
{
if (end < 0)
{
throw new ArgumentOutOfRangeException(nameof(end), "Must be larger than 0");
}
for (var i = 0; i <= end; i++)
{
switch (i % 2)
{
case 1:
yield return i;
break;
default:
yield break;
}
}
}
foreach (var i in GetOddSequenceEnumerator(100))
{
Console.WriteLine($"{i} is Odd.");
}
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
}