-
Notifications
You must be signed in to change notification settings - Fork 0
/
task3.cs
41 lines (35 loc) · 1.12 KB
/
task3.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
/*
----------------------------------------------------------------
https://www.codewars.com/kata/517abf86da9663f1d2000003/train/csharp
----------------------------------------------------------------
*/
using System;
using System.Collections.Generic;
public class Kata
{
public static string ToCamelCase(string str)
{
Console.WriteLine(str);
List<string> sectorsList = new List<string>();
string result = "";
string _str = str.Replace('-', '_');
Console.WriteLine(_str);
foreach(char chr in _str)
{
var sectors = _str.Split('_');
foreach (string sector in sectors) { sectorsList.Add(sector); }
break;
}
foreach(string sector in sectorsList)
{
if(sector.Length > 0)
{
char upperChar = Char.ToUpper(sector[0]);
result += upperChar + sector.Remove(0, 1);
}
}
if (result.Length > 0 && !Char.IsUpper(_str[0])) result = Char.ToLower(result[0]) + result.Remove(0, 1);
Console.WriteLine(result);
return result;
}
}