I was asked for my 'input' on a piece of code written by a young programmer in an interview. They hinted at a potential issue and stated that it would be frequently employed on huge strings.
public string ReverseString(string sz)
string result = string.Empty;
for(int i = sz.Length-1; i>=0; i--)
result += sz[i]
I was unable to locate it. There were no issues that I noticed. In retrospect, I could have suggested the user should resize, but C# doesn't appear to have one (I'm a C++ guy).
I ended up putting things like utilise an iterator if possible, [x] in containers could not be random access, therefore it would be sluggish, and so on. and a few other things However, I specifically stated that I had never had to optimise C# code, indicating that my reasoning did not fail me during the interview.
I'm curious as to what the issue is with this code; do you see it?