-1
因此,我已经完成了所有代码的编写,但我只能弄清楚如何更改预定字符的值,在本例中为e,其中I需要的值与当前字符改变,因为它遍历文本提前如何在一行文本中一次识别单个字符
感谢
static void Encrypt()
{
int asciiVal;
string CurrentLine;
StreamReader CurrentReadFile = new StreamReader("EncMe.txt");
StreamWriter CurrentWriteFile = new StreamWriter("temp.txt");
while (!CurrentReadFile.EndOfStream)
{
string EncLine = "";
CurrentLine = CurrentReadFile.ReadLine();
foreach (char e in CurrentLine)
{
char CurrentChar = 'e';
asciiVal = (int)CurrentChar;
asciiVal = asciiVal + 1;
CurrentChar = (char)asciiVal;
EncLine = EncLine + CurrentChar;
}
CurrentWriteFile.WriteLine(EncLine);
}
CurrentWriteFile.Close();
CurrentReadFile.Close();
}
'char CurrentChar ='e';'应该是'char CurrentChar = e;' –
我不明白你在问什么。你是否试图在C#中实现凯撒密码?请注意,您并未使用“e”变量。请[编辑]你的问题,包括输入,你得到的输出和你期望的输出。 –