-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphoneNumber.cs
More file actions
53 lines (42 loc) · 1.1 KB
/
Copy pathphoneNumber.cs
File metadata and controls
53 lines (42 loc) · 1.1 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace phoneNumber
{
class Program
{
static void Main(string[] args)
{
int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
Kata.CreatePhoneNumber(numbers);
}
}
public class Kata
{
public static string CreatePhoneNumber(int[] numbers)
{
List<string> stringList = new List<string>();
int counter = 0;
string phone = null;
foreach (var item in numbers)
{
if (counter == 0)
stringList.Add("(");
stringList.Add(item.ToString());
if (counter == 2)
stringList.Add(") ");
if (counter == 5)
stringList.Add("-");
counter++;
}
foreach (var item in stringList)
{
phone += item;
}
Console.WriteLine(phone);
return phone;
}
}
}