+ 3
Someone please help. *PROBLEM SOLVED*
I have been working on a project, and something happens that's not supposed to. Either that or I'm unbelievably dumb. The code returns 1 even though it should (probably) return two. This only happens in a loop. (Maybe it doesn't, but I need it to be in a loop.) Thanks to everyone here for their help. https://code.sololearn.com/cOQZ6KZ1PnZe/?ref=app
4 Answers
+ 20
@WdBros
Can you change this statement it will output 2.
one=one.Replace(one[0].ToString(), two.ToString());
https://code.sololearn.com/cmX4iyineGKr/?ref=app
+ 16
Why?
No error.
+ 8
You caught me white fluffy cat! â€
@luka and @Nithiwat are correct, you just forgot to reassign as the Replace function will return a *NEW* string after replacement. (Remember string is immutable)
I just prepared a demo too and hopefully it helps! đ
https://code.sololearn.com/cX112mbF0hcW/?ref=app
+ 6
Additional info; Convert.ToChar(int) returns a Unicode character based on the value of the integer passed in. Convert.ToChar(65) outputs 'A', instead of '65'. Your code Convert.ToChar(two) returned a non printable character.
https://msdn.microsoft.com/en-us/library/3hkfdkcx(v=vs.110).aspx