C
Join ServerC#
help
❔ ✅ using multiple methods to object
RRyan-T141212/24/2022
.

RRyan-T141212/24/2022
ok so before reversing the string
RRyan-T141212/24/2022
we should convert it to an array, right?
RRyan-T141212/24/2022
why it's not
number.ToArray().Reverse()
Tthinker22712/24/2022
string
already implements IEnumerable<char>
so there's no need toTthinker22712/24/2022
Also
new string(numb.ToString())
isn't necessary, you can just do numb.ToString()
RRyan-T141212/24/2022
how about next line ?
RRyan-T141212/24/2022
string reversedNumber = new string(number.Reverse().ToArray());
RRyan-T141212/24/2022
if i remove new string it gaves an error
Tthinker22712/24/2022
You need it there because
ToArray()
returns a char[]
, and new string
creates a string from a char[]
.RRyan-T141212/24/2022
i see
RRyan-T141212/24/2022
string reversedNumber = number.Reverse();
RRyan-T141212/24/2022
but what if i do it like this
RRyan-T141212/24/2022
insted of converting string -> array -> string
Tthinker22712/25/2022
That won't work because you can't convert an
IEnumerable<char>
to a string
.EEro12/25/2022
Now i wonder what the fastest way to reverse is...
Tthinker22712/25/2022
string.Create
probablyEEro12/25/2022
Because it always is
EEro12/25/2022
But there's more nuance to it
EEro12/25/2022
Because you don't necessarily have to turn the number into a string first
Tthinker22712/25/2022
however, that was not the question, so let's not get sidetracked 

EEro12/25/2022
I wanna side track!
Tthinker22712/25/2022
go to #allow-unsafe-blocks 

RRyan-T141212/25/2022
thank you
RRyan-T141212/25/2022
!close
AAccord12/25/2022
Closed!
AAccord12/26/2022
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.