I would prefer the first one for a few reasons.
- It's more readable and easily understandable in my opinion.
- There's only one string, so less overhead. (Which is negligible unless this is being called a lot.)
- There's only one array. Reverse creates a second array.
That being said, an actual review is in order.
- Methods that return a boolean value should have names of the form
IsSomething
orHasSomething
. A great name would beIsPalindrome
. - Neither method accepts anything but a string. Numbers can be palindromic too. Wouldn't it be a nice addition if we could pass an integer to it as well? (Without explicitly calling
.ToString()
before passing it in that is.) - I like that you're only checking for
i < j
instead ofi <= j
. It saves a useless iteration when there are an odd number of characters. - I also like the
while
loop. It's a lot cleaner than thefor
loop suggested by another answer. - I won't speak much on the second method, because I think @elios provided a nice implementation of it @elios provided a nice implementation of it.
I would prefer the first one for a few reasons.
- It's more readable and easily understandable in my opinion.
- There's only one string, so less overhead. (Which is negligible unless this is being called a lot.)
- There's only one array. Reverse creates a second array.
That being said, an actual review is in order.
- Methods that return a boolean value should have names of the form
IsSomething
orHasSomething
. A great name would beIsPalindrome
. - Neither method accepts anything but a string. Numbers can be palindromic too. Wouldn't it be a nice addition if we could pass an integer to it as well? (Without explicitly calling
.ToString()
before passing it in that is.) - I like that you're only checking for
i < j
instead ofi <= j
. It saves a useless iteration when there are an odd number of characters. - I also like the
while
loop. It's a lot cleaner than thefor
loop suggested by another answer. - I won't speak much on the second method, because I think @elios provided a nice implementation of it.
I would prefer the first one for a few reasons.
- It's more readable and easily understandable in my opinion.
- There's only one string, so less overhead. (Which is negligible unless this is being called a lot.)
- There's only one array. Reverse creates a second array.
That being said, an actual review is in order.
- Methods that return a boolean value should have names of the form
IsSomething
orHasSomething
. A great name would beIsPalindrome
. - Neither method accepts anything but a string. Numbers can be palindromic too. Wouldn't it be a nice addition if we could pass an integer to it as well? (Without explicitly calling
.ToString()
before passing it in that is.) - I like that you're only checking for
i < j
instead ofi <= j
. It saves a useless iteration when there are an odd number of characters. - I also like the
while
loop. It's a lot cleaner than thefor
loop suggested by another answer. - I won't speak much on the second method, because I think @elios provided a nice implementation of it.
I would prefer the first one for a few reasons.
- It's more readable and easily understandable in my opinion.
- There's only one string, so less overheardoverhead. (Which is negligible unless this is being called a lot.)
- There's only one array. Reverse creates a second array.
That being said, an actual review is in order.
- Methods that return a boolean value should have names of the form
IsSomething
orHasSomething
. A great name would beIsPalindrome
. - Neither method accepts anything but a string. Numbers can be palindromic too. Wouldn't it be a nice addition if we could pass an integer to it as well? (Without explicitly calling
.ToString()
before passing it in that is.) - I like that you're only checking for
i < j
instead ofi <= j
. It saves a useless iteration when there are an odd number of characters. - I also like the
while
loop. It's a lot cleaner than thefor
loop suggested by another answer. - I won't speak much on the second method, because I think @elios provided a nice implementation of it.
I would prefer the first one for a few reasons.
- It's more readable and easily understandable in my opinion.
- There's only one string, so less overheard. (Which is negligible unless this is being called a lot.)
- There's only one array. Reverse creates a second array.
That being said, an actual review is in order.
- Methods that return a boolean value should have names of the form
IsSomething
orHasSomething
. A great name would beIsPalindrome
. - Neither method accepts anything but a string. Numbers can be palindromic too. Wouldn't it be a nice addition if we could pass an integer to it as well? (Without explicitly calling
.ToString()
before passing it in that is.) - I like that you're only checking for
i < j
instead ofi <= j
. It saves a useless iteration when there are an odd number of characters. - I also like the
while
loop. It's a lot cleaner than thefor
loop suggested by another answer. - I won't speak much on the second method, because I think @elios provided a nice implementation of it.
I would prefer the first one for a few reasons.
- It's more readable and easily understandable in my opinion.
- There's only one string, so less overhead. (Which is negligible unless this is being called a lot.)
- There's only one array. Reverse creates a second array.
That being said, an actual review is in order.
- Methods that return a boolean value should have names of the form
IsSomething
orHasSomething
. A great name would beIsPalindrome
. - Neither method accepts anything but a string. Numbers can be palindromic too. Wouldn't it be a nice addition if we could pass an integer to it as well? (Without explicitly calling
.ToString()
before passing it in that is.) - I like that you're only checking for
i < j
instead ofi <= j
. It saves a useless iteration when there are an odd number of characters. - I also like the
while
loop. It's a lot cleaner than thefor
loop suggested by another answer. - I won't speak much on the second method, because I think @elios provided a nice implementation of it.
I would prefer the first one for a few reasons.
- It's more readable and easily understandable in my opinion.
- There's only one string, so less overheard. (Which is negligible unless this is being called a lot.)
- There's only one array. Reverse creates a second array.
That being said, an actual review is in order.
- Methods that return a boolean value should have names of the form
IsSomething
orHasSomething
. A great name would beIsPalindrome
. - Neither method accepts anything but a string. Numbers can be palindromic too. wouldn'tWouldn't it be a nice addition if we could pass an integer to it as well? (Without explicitly calling
.ToString()
before passing it in that is.) - I like that you're only checking for
i<ji < j
instead ofi <= j
. It saves a useless iteration when there are an odd number of characters. - I also like the
while
loop. It's a lot cleaner than thefor
loop suggested by another answer. - I won't speak much on the second method, because I think @elios provided a nice implementation of it.
I would prefer the first one for a few reasons.
- It's more readable and easily understandable in my opinion.
- There's only one string, so less overheard. (Which is negligible unless this is being called a lot.)
- There's only one array. Reverse creates a second array.
That being said, an actual review is in order.
- Methods that return a boolean value should have names of the form
IsSomething
orHasSomething
. A great name would beIsPalindrome
. - Neither method accepts anything but a string. Numbers can be palindromic too. wouldn't it be nice if we could pass an integer to it as well? (Without explicitly calling
.ToString()
before passing it in that is.) - I like that you're only checking for
i<j
instead ofi <= j
. It saves a useless iteration when there are an odd number of characters. - I also like the
while
loop. It's a lot cleaner than thefor
loop suggested by another answer. - I won't speak much on the second method, because I think @elios provided a nice implementation of it.
I would prefer the first one for a few reasons.
- It's more readable and easily understandable in my opinion.
- There's only one string, so less overheard. (Which is negligible unless this is being called a lot.)
- There's only one array. Reverse creates a second array.
That being said, an actual review is in order.
- Methods that return a boolean value should have names of the form
IsSomething
orHasSomething
. A great name would beIsPalindrome
. - Neither method accepts anything but a string. Numbers can be palindromic too. Wouldn't it be a nice addition if we could pass an integer to it as well? (Without explicitly calling
.ToString()
before passing it in that is.) - I like that you're only checking for
i < j
instead ofi <= j
. It saves a useless iteration when there are an odd number of characters. - I also like the
while
loop. It's a lot cleaner than thefor
loop suggested by another answer. - I won't speak much on the second method, because I think @elios provided a nice implementation of it.