+ 1

Help with ToLower() in C#

I need to convert a camelString to a snake_string. I was able to add the underscore (_) before each upperCase in all cases. But when I try to convert all the upperCase letters to lowercase, the program gives an error. I've finally added "using System.Globilization" but it didn't change anything for the missing culture info error. What can I do to solve this? https://code.sololearn.com/cjZowmfzv17P/?ref=app

15th Aug 2021, 3:48 PM
Aykut AKSAKAL
Aykut AKSAKAL - avatar
9 Respuestas
+ 5
For line 27 try Console.WriteLine( s.ToString().ToLower() );
15th Aug 2021, 3:54 PM
Ipang
+ 2
Ipang ohh I finally made a wild guess and solved the puzzle!
15th Aug 2021, 4:11 PM
Aykut AKSAKAL
Aykut AKSAKAL - avatar
+ 2
Test Case 5 is invisible, so I couldn't understand what the missing part or the mistake is. But then I made a wild guess checking my code and decided to add (... && i !=0) for the condition in the loop. Then it passed in all the test cases. I guess the input's initial letter is an upper case. And because my loop adds an underscore before each upper cases before converting to whole string to a lower case, the program outputs the last Test Case's result as "_some_thing" with an underscore just at the head of the string. That's why I decided to add (... && i !=0) in the condition. https://code.sololearn.com/c6Z0Rxzc9ax1/?ref=app
15th Aug 2021, 4:18 PM
Aykut AKSAKAL
Aykut AKSAKAL - avatar
+ 2
What do you know, wild guesses works at times 😆👍
15th Aug 2021, 4:27 PM
Ipang
+ 1
Ipang that also gave an error. So, I did this: string snake = s.ToString(); snake = snake.ToLower(); Console.WriteLine(snake); now it works fine. Thanks. But in the challange it doesn't pass the Test Case 5 (I dont know why, and I cant see either test input or the mistake in the output). Thanks anyway though :) it's dumb of me to forget ToString after the StringBuilder.. these SoloLearn challanges..
15th Aug 2021, 4:01 PM
Aykut AKSAKAL
Aykut AKSAKAL - avatar
+ 1
Yeah I kinda get how it feels like, many also had difficulty with the coach's challenge cases.. Maybe try to look for some threads covering this challenge. If you're lucky maybe you find your way 👍
15th Aug 2021, 4:04 PM
Ipang
+ 1
I did that beforehand and I saw some in python and c++, but not in c#. :) I think c sharpers quit it after a while 😂
15th Aug 2021, 4:08 PM
Aykut AKSAKAL
Aykut AKSAKAL - avatar
+ 1
Hey just describe it along, someone who go and try that challenge later might find it helpful ...
15th Aug 2021, 4:13 PM
Ipang
0
I also tried this at the end: string snake = s.ToLower(); Console.WriteLine(snake);
15th Aug 2021, 3:50 PM
Aykut AKSAKAL
Aykut AKSAKAL - avatar