C#将主字符串的长度设置为子字符串的长度

C#将主字符串的长度设置为子字符串的长度,c#,C#,我对.length代码有问题 using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program { static void Main(string[] args) { string Str_Basics = "AIKdepNCZSIDETe"; int Long_Str_Bas; string Su

我对
.length
代码有问题

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string Str_Basics = "AIKdepNCZSIDETe";
        int Long_Str_Bas;
        string Sub_Str_1;
        string Sub_Str_2;
        Long_Str_Bas = Str_Basics.Length;

        //Provide value for M
        int M = 0;
        Console.WriteLine("Provide value for M");
        M = Convert.ToInt32(Console.ReadLine());

        for (int i = 0; i < Long_Str_Bas; i++) ;

        // First substring
        Sub_Str_1 = Str_Basics.Substring(1, (M - 1));

        // Second substring
        Sub_Str_2 = Str_Basics.Substring((M + 1),Long_Str_Bas);
        Console.WriteLine("Substring is " + Sub_Str_1);
        Console.WriteLine("Substring is " + Sub_Str_2);
        Console.ReadKey();
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
班级计划
{
静态void Main(字符串[]参数)
{
字符串Str_Basics=“AIKdepNCZSIDETe”;
国际龙湖街;
字符串Sub_Str_1;
字符串Sub_Str_2;
Long_Str_Bas=Str_Basics.Length;
//为M提供价值
int M=0;
Console.WriteLine(“为M提供值”);
M=Convert.ToInt32(Console.ReadLine());
对于(int i=0;i

我不知道如何将
Str\u Basics.Length
转换成
Sub\u stru\u 2
的坐标,如果有人能解释
.Length
是如何工作的,我将非常感谢。

听起来你只是想这样做:

    // First substring
    Sub_Str_1 = Str_Basics.Substring(0, M);

    // Second substring
    Sub_Str_2 = Str_Basics.Substring(M);

我真的不清楚你想要实现什么
.Length
只是返回字符串长度的只读属性。你想用它做什么?看起来你想在用户在位置M给出的位置拆分一个字符串。但是你所要求的看起来与代码中的任何东西都不相似。因此需要更详细的解释。此外,for循环在编写时什么也不做。从代码中,您似乎想知道方法
子字符串(int startIndex,int length)的
length
参数是如何工作的
而不是
string
类的属性
Length
,这是否正确?抱歉,我写得很匆忙。是的,我想知道是否可以将lenght参数转换为定义另一个字符串长度的数字。我想我修改了这行Sub_Str_2=Str_Basics.Substring((M+1),(A-(M+1));