-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
40 lines (35 loc) · 1.15 KB
/
Program.cs
File metadata and controls
40 lines (35 loc) · 1.15 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
using System;
namespace StringToCommaChars
{
class Program
{
static void Main(string[] args)
{
string result = "";
while(result.ToLower() != "exit")
{
Console.WriteLine("\nType in a string to convert to comma-delimited chars (type 'exit' to quit):");
result = Console.ReadLine();
Console.Write("Size: ");
Console.WriteLine(result.Length + 1);
Console.WriteLine("As chars:");
for (int i = 0; i < result.Length; i++)
{
Console.Write("'");
Console.Write(result[i]);
Console.Write("',");
}
Console.WriteLine("0,");
Console.WriteLine("As decimal:");
for (int i = 0; i < result.Length; i++)
{
Console.Write((uint)result[i]);
Console.Write(",");
}
Console.WriteLine("0,");
}
Console.WriteLine("\nPress any key to quit...");
Console.ReadKey();
}
}
}