Synchronization of old projects
Part1
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,58 @@
|
||||
#region 知识点一 基本概念
|
||||
//交错数组 是 数组的数组,每个维度的数量可以不同
|
||||
//注意:二维数组的每行的列数相同,交错数组每行的列数可能不同
|
||||
//一般情况下都用于行列数不一的情况
|
||||
#endregion
|
||||
|
||||
#region 知识点二 数组的声明
|
||||
//1.变量类型[][] 交错数组名;
|
||||
int[][] arr1;
|
||||
|
||||
//2.变量类型[][] 交错数组名 = new 变量类型[行数][];
|
||||
int[][] arr2 = new int[3][];
|
||||
|
||||
//3.变量类型[][] 交错数组名 = new 变量类型[行数][]{一维数组,一维数组2,......};
|
||||
int[][] arr3 = new int[3][] { new int[] {1,2,3 },
|
||||
new int[] {1,2},
|
||||
new int[] {1,2,3 }
|
||||
};
|
||||
//4.变量类型[][] 交错数组名 = new 变量类型[][]{一维数组,一维数组2,......};
|
||||
int[][] arr4 = new int[][] { new int[] {1,2,3 },
|
||||
new int[] {1,2},
|
||||
new int[] {1,2,3 }
|
||||
};
|
||||
//5.变量类型[][] 交错数组名 = {一维数组,一维数组2,......};
|
||||
int[][] arr5 = { new int[] {1,2,3 },
|
||||
new int[] {1,2},
|
||||
new int[] {1,2,3 }
|
||||
};
|
||||
#endregion
|
||||
|
||||
#region 知识点三 数组的使用
|
||||
int[][] array = { new int[] { 1,2,3},
|
||||
new int[] {4,5}
|
||||
};
|
||||
//1.数组长度
|
||||
//行
|
||||
Console.WriteLine(array.GetLength(0));
|
||||
//列(得到某一行的列数
|
||||
Console.WriteLine(array[0].Length);
|
||||
|
||||
//2.获取交错数组中的元素(注意别越界
|
||||
Console.WriteLine(array[0][1]);
|
||||
|
||||
//3.修改元素(同上
|
||||
array[0][1] = 99;
|
||||
|
||||
//4.遍历
|
||||
for (int i = 0; i < array.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < array[i].Length; j++)
|
||||
{
|
||||
Console.Write(array[i][j]+"\t");
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
//5.增删查(懒得写)
|
||||
#endregion
|
||||
Reference in New Issue
Block a user