3
namespace CosmosKernel2
{
    public class Kernel : Sys.Kernel
    {
        protected override void BeforeRun()
        {
           Console.WriteLine("hi.");
        }
        protected override void Run()
        {
            Console.WriteLine("Input:");
            String input = Console.ReadLine();
        if (input.StartsWith("echo"))
            {
               var index = input.LastIndexOf(input);  // ERROR HERE
               Console.WriteLine("echo: " + input.Substring(cmdLastIndex));
            }}}}

我正在制作一个简单的操作系统来回显用户的输入。但是,我遇到了一些错误。我认为创建 var 索引和存储最后一个索引没有任何问题。

这是我的错误:

 Build started: Project: CosmosKernel2Boot, Configuration: Debug x86 ------
1>  Invoking il2cpu.exe "DebugEnabled:True" "StackCorruptionDetectionEnabled:False" "DebugMode:Source" "TraceAssemblies:" "DebugCom:1" "UseNAsm:True" "OutputFilename:C:\Users\Lindsay\Documents\Visual Studio 2015\Projects\CosmosKernel2\CosmosKernel2\bin\Debug\CosmosKernel2Boot.asm" "EnableLogging:True" "EmitDebugSymbols:True" "IgnoreDebugStubAttribute:False" "References:C:\Users\Lindsay\Downloads\Cosmos User Kit\Kernel\Cosmos.Core.Plugs.dll" "References:C:\Users\Lindsay\Downloads\Cosmos User Kit\Kernel\Cosmos.Debug.Kernel.Plugs.dll" "References:C:\Users\Lindsay\Downloads\Cosmos User Kit\Kernel\Cosmos.System.Plugs.dll" "References:C:\Users\Lindsay\Documents\Visual Studio 2015\Projects\CosmosKernel2\CosmosKernel2\bin\Debug\CosmosKernel2.dll" "References:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll" 
1>C:\Program Files (x86)\MSBuild\Cosmos\Cosmos.targets(31,5): error : Error occurred while invoking IL2CPU.
1>  Executing command line "C:\Users\Lindsay\Downloads\Cosmos User Kit\Build\IL2CPU\IL2CPU.exe" "DebugEnabled:True" "StackCorruptionDetectionEnabled:False" "DebugMode:Source" "TraceAssemblies:" "DebugCom:1" "UseNAsm:True" "OutputFilename:C:\Users\Lindsay\Documents\Visual Studio 2015\Projects\CosmosKernel2\CosmosKernel2\bin\Debug\CosmosKernel2Boot.asm" "EnableLogging:True" "EmitDebugSymbols:True" "IgnoreDebugStubAttribute:False" "References:C:\Users\Lindsay\Downloads\Cosmos User Kit\Kernel\Cosmos.Core.Plugs.dll" "References:C:\Users\Lindsay\Downloads\Cosmos User Kit\Kernel\Cosmos.Debug.Kernel.Plugs.dll" "References:C:\Users\Lindsay\Downloads\Cosmos User Kit\Kernel\Cosmos.System.Plugs.dll" "References:C:\Users\Lindsay\Documents\Visual Studio 2015\Projects\CosmosKernel2\CosmosKernel2\bin\Debug\CosmosKernel2.dll" "References:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll" 
1>  Working directory = 'C:\Users\Lindsay\Documents\Visual Studio 2015\Projects\CosmosKernel2\CosmosKernel2\bin\Debug\'
4

1 回答 1

0

看起来你指的是 undefined variable cmdLastIndex。您应该将其重命名为index.

Console.WriteLine("echo: " + input.Substring(cmdLastIndex));
于 2016-10-26T02:13:29.973 回答