var并存储最后一个错误索引

时间:2016-10-25 21:39:36

标签: c# cosmos

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\'

1 个答案:

答案 0 :(得分:0)

您好像是指未定义的变量cmdLastIndex。您应该将其重命名为index

Console.WriteLine("echo: " + input.Substring(cmdLastIndex));