Ok so i want to write a windows form in c# that encrypts and/or decrypts words/sentence/letters with the cesar shift encryption, i think i already have some good coding but i don't really know where to put what for the form programming, when i execute it and start writing something to encrypt/decrypt it just freezes after the first letter i enter

public partial class Encrypt : Form
{
public Encrypt()
{
InitializeComponent();
}
public string phrase;
public char legend;
public char val;
public int key;
public string encryptedstring;
static public char EncryptChar(int key, char val, char[] legend)
{
int i = Array.IndexOf(legend, val) + key;
if (i >= legend.Length)
{
i -= legend.Length;
}
return legend[i];
}
static public char DecryptChar(int key, char val, char[] legend)
{
int i = Array.IndexOf(legend, val) - key;
if (i < 0)
{
i += legend.Length;
}
return legend[i];
}
private void txtPhrase_TextChanged(object sender, EventArgs e)
{
phrase = Convert.ToString(Console.ReadLine());
}

private void btnEncrypt_Click(object sender, EventArgs e)
{
char[] legend = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
int i = Array.IndexOf(legend, val) + key;
if (i >= legend.Length)
{
i -= legend.Length;
}
string stringtoencrypt = phrase;
string encryptedstring = "";
foreach (char dd in stringtoencrypt.ToCharArray())
{
encryptedstring += EncryptChar(3, dd, legend);
}
lblPhrase.Text = ("Encryption: " + encryptedstring);
lblPhrase.Visible = true;
}

private void btnDecrypt_Click(object sender, EventArgs e)
{
char[] legend = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
int i = Array.IndexOf(legend, val) - key;
if (i < 0)
{
i += legend.Length;
}
string stringtoencrypt = phrase;
string decryptedstring = "";
foreach (char dd in encryptedstring.ToCharArray())
{
decryptedstring += DecryptChar(3, dd, legend);
}
lblPhrase.Text = ("Decryption: " + decryptedstring);
lblPhrase.Visible = true;
}

private void lblPhrase_Click(object sender, EventArgs e)
{

}

private void btnFin_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}