jeudi 2 mars 2017

while... cycle ends after if statement in public static method C#

I wrote some code in public static method with cycle "while". But this cycle ends after "if" statement, and application doesn't throw any exception. Here is the code:

public static void ShortcutDetect()
{
    ShortkeyIndex = 0;
    while(ShortkeyIndex < 1000) 
    {
        File.WriteAllText(@"C:\Users\OEM\Desktop\log.txt",
            File.ReadAllText(@"C:\Users\OEM\Desktop\log.txt") + Convert.ToString(ShortkeyIndex));
        if(Program.key.Replace("LShiftKey","Shift")
            .Replace("RShiftKey","Shift").Replace("RMenu","Alt")
            .Replace("LMenu","Alt").Replace("RControlKey","Ctrl")
            .Replace("LControlKey","Ctrl").EndsWith(RawShortkeys[ShortkeyIndex]))
        {
            MessageBox.Show(RawShortkeys[ShortkeyIndex]);
        }
        ShortkeyIndex++;
    }
}

Thanks beforehand.

Aucun commentaire:

Enregistrer un commentaire