Error with some code

Apr 14, 2012 at 11:21 PM


                    for (int i = 0; i < Core.FileSystem.VFS.HardDrive.Drive.GetDisk("C").GetFiles(); i ++)
                        string data = Core.FileSystem.VFS.HardDrive.Drive.GetDisk("C").files[i].data;
                        Console.Write("Enter the name of the file");
                        var rf = Console.ReadLine();
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("The file doesn't exist. !!");

Hi this code is from the Arkadia OS and when I use it I get this error:

Warning    1    Unreachable code detected  

What to do??

Apr 15, 2012 at 4:42 AM

IMHO you should learn C# first before starting writing Cosmos code.

Well, it is not a real error, but a warning which mentions that the for loop you are writing is unnecessary, because you are jumping out of the for loop at the first iteration.

Means: i is set to 0. After the Console.WriteLine you jump out of the for loop (and the function). Remove the return; to remove the warning - if it is your intention (in terms of behaviour).