I didn't try and run the code, but I think I know where's the problem.
In C++ you're doing this:
Code:
codon.append(RNA.substr(beginIndex,endIndex-beginIndex));
// and then later...
protein.append(aminoAcids[k]);
So, in the code above, you are appending the new string to the existing cumulative string.
In C#, though, you're doing this:
Code:
codon=(RNA.Substring(beginIndex, endIndex - beginIndex));
// and later...
protein = (aminoAcids[k]);
This simply replaces the entire string with a new one, which is why you end up with only one codon and one amino acid - the one which was the last in the sequence entered (right?).
You can use the += operator, which will append the string instead.
An expression of the form
someString += otherString;
is simply a shorthand for:
someString = someString + otherString;
So you can try this (BTW, the outer "(" and ")" are not required):
Code:
codon += RNA.Substring(beginIndex, endIndex - beginIndex);
// and later...
protein += aminoAcids[k];
Or, if you need some kind of a separator in between:
Code:
codon += RNA.Substring(beginIndex, endIndex - beginIndex) + " ";
// and later...
protein += aminoAcids[k] + " ";
Also, make sure that there aren't any more errors of the same sort in other parts of the program, since I may have missed them.