Rotational Cipher

in #ita5 days ago

using System;

public static class RotationalCipher
{
public static string Rotate(string text, int shiftKey){
string letterN = "";
shiftKey %= 26;
foreach(char i in text){
if(char.IsUpper(i)){
char res = (char) ('A' + (i - 'A' + shiftKey) % 26);
letterN += res;
}
else if (Char.IsLower(i)){
char res = (char) ('a' + (i - 'a' + shiftKey) % 26);
letterN += res;
}

        else {
            letterN += i;
        }
    }
    return letterN;
}

}