Var并存储错误的最后索引

本文关键字:最后 索引 错误 存储 Var | 更新日期: 2023-09-27 18:14:59

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

Var并存储错误的最后索引

看起来您指的是未定义的变量cmdLastIndex。你应该把它重命名为index

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