12 Replies
ero
REPL Result: Success
Result: bool
Compile: 774.662ms | Execution: 38.325ms | React with ❌ to remove this embed.
take a look at what
Reverse()
returnsReverse()
returns:
I don't understand whyA string is nothing more than a
char[]
And .Reverse()
works on collections, and returns a collection
So, under the hood, it converts the string
into a char[]
And returns a reversed char[]
Angius
REPL Result: Success
Result: ReverseIterator<char>
Compile: 526.269ms | Execution: 46.645ms | React with ❌ to remove this embed.
Reverse()
does not return a string, therefore you can't compare it with a string.
You have two options:
- Use x.ToString().Reverse().SequenceEqual(x.ToString())
which compares whether two sequences of things (char
s in this case) contain the same items.
- Change approach and use a for loop to go through the string and compare each character with another at the other end of the string.I'm the only one wonder why this method take an int as parameter ?
Well, what do the docs say?
He means the user method I think
Ah, the
IsPalindrome()
?
No clue, seems uselessProbably to prove out with a small subset of data
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.