Simple Caesar shifter in C# I use these in a windows form with fun buttons, I wanted to see what the world thinks of my coding.

This is something that I coded about 2-3 years ago, I did change some of the coding when I looked at it and thought "this could be better written like this"

Let me know what you think and what I could do differently.

Public class shiftCipher
{
    public string removeSpaces(string plainIn)
    {
        plainIn = plainIn.Replace(" ", string.Empty);
        return plainIn;
    }

    public string reverse(string plainIn)
    {
        char[] charArray = plainIn.ToCharArray();
        Array.Reverse(charArray);

        return new string(charArray);
    }

    public string toUCase(string strIn)
    {
        strIn = strIn.ToUpper();
        return strIn;
    }

    public string shift(string plainIn, int shift)
    {// 65=a 90=z in ASCII
        string readOut=string.Empty;
        char[] charArray;

        charArray = plainIn.ToCharArray();
        for (int i = 0; i &lt; plainIn.Length; i++)
        {
            int Num = Convert.ToInt32(charArray[i]) + shift;
            readOut += Convert.ToChar(Num &gt; 90 ? Num -= 26 : (Num &lt; 65 ? Num += 26: Num));
        }
        return readOut;
    }

    //this method will take all of these methods and put them together to encrypt
    public string Encrypt(string ReadIn, int Shift)
    {
        ReadIn = removeSpaces(ReadIn);
        ReadIn = reverse(ReadIn);
        ReadIn = toUCase(ReadIn);
        ReadIn = shift(ReadIn, Shift);
        return ReadIn;
    }

    public string Decrypt(string ReadIn, int amountShift)
    {
        ReadIn = reverse(ReadIn);// undo the reverse by running the method again
        ReadIn = shift(ReadIn, -amountShift);

        return ReadIn;
    }       
}


In the Decrypt I didn't think there was a good way to put the spaces back into the string, so I didn't try to take that on, and I also left the string in uppercase if it was there.
Simpler Methods.

the code:


public string removeSpaces(string plainIn)
{
    plainIn = plainIn.Replace(" ", string.Empty);
    return plainIn;
}



Could be:

public string removeSpaces(string plainIn)
{
    return plainIn.Replace(" ", string.Empty);
}


Which begs the question... why have the removeSpaces method at all?

The same is true with toUCase()

Simpler Conversion

Why use Convert.ToInt32(....); and Convert.ToChar(...) when (int) and (char) will do?

Simpler Math

This line here (the crux of the problem), can be simplified using modulo and removing the Magic Numbers:


int Num = Convert.ToInt32(charArray[i]) + shift;
readOut += Convert.ToChar(Num &gt; 90 ? Num -= 26 : (Num &lt; 65 ? Num += 26: Num));



can be:

// Constants....
private const int LETTERA = (int)'A';
private const int LETTERCOUNT = (int)'Z' - LETTERA + 1;

// actual code.
 readOut += (char)(LETTERA + (((int)charArray[i] + shift - LETTERA + LETTERCOUNT) % LETTERCOUNT));


(See ideone here)

Without the conditional / ternary operator it is more likely to be tighter/faster code as well.

Comments

You have used magic numbers, so you attempted to document them with a comment:


public string shift(string plainIn, int shift)
{// 65=a 90=z in ASCII



But, the comments are wrong, and misleading (wrong case character).

 {// 65=A 90=Z in ASCII


Symmetry

When you have methods that do symmetrical work (they are closely related), then you should ensure the parameter names are the same.... For example, you have:


public string Encrypt(string ReadIn, int Shift)



and 


public string Decrypt(string ReadIn, int amountShift)



The second should have the parameter name Shift