gpt4 book ai didi

c# - 动态创建数组并在 C# 中比较它们

转载 作者:太空宇宙 更新时间:2023-11-03 21:35:20 24 4
gpt4 key购买 nike

我的基本要求是比较一些字符串数组,然后找出它们是否相同。

基本上我会得到一个计数,并根据该计数动态创建数组。

例如,我的查询计数为 2,因此我需要创建 2 个数组并在 for 循环中访问该数组

就像计数 2 的情况

Arrays: string[] array0 = new string[100];
string[] array1 = new string[100];

在 for 循环中,我需要在索引为 0 时访问 array0,在索引值为 1 时访问 array1

here count = 2 suppose.
for (int i = 0 ;i <count;i++)
{
when 0 then access array0 and when 1 then access array1
}

但我无法通过这种方式获得 array0 和 array1 的引用。任何人都可以指导我正确的方向。

谢谢。

最佳答案

尝试将数组存储在Array

string[][] AllMyArrays = new string[][count];
for (int i = 0; i < count; i++)
AllMyArrays[i] = new string[100];

这样你就可以索引它们整个数组

关于c# - 动态创建数组并在 C# 中比较它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22139174/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com