[英]C# I have two lists. I want to compare them
I have a very complex problem. 我有一个非常复杂的问题。 At least to me it is, since I am a beginner. 至少对我来说,因为我是初学者。
I have 2 List(string) lists. 我有2个列表(字符串)列表。
One of them is filled with currency ISO codes. 其中之一充满了货币ISO代码。 Second is their value. 其次是他们的价值。 Both lists have 332 lines. 两个列表都有332行。
I want to compare a Console.ReadLine(); 我想比较一个Console.ReadLine(); input with the currency ISO codes list. 输入货币ISO代码列表。
If it is contained in the list to get it's row number. 如果它包含在列表中以获取它的行号。
Then get that row number and use it to get the same row from the value list. 然后获取该行号,并使用它从值列表中获取同一行。
Here is the code: 这是代码:
download = empty16.Replace(download, "");
StringBuilder sb1 = new StringBuilder();
for (int iaU = 0; iaU < download.Length; iaU++)
{
if (iaU%3 == 0)
sb1.Append('\n');
sb1.Append(download[iaU]);
}
string formDown = sb1.ToString();
List<string> formFin = formDown.Split('\n').ToList(); //This is the ISO list
List<string> l1st = new List<string>();
int iwNz = 0;
while (iwNz < intVal)
{
string sub = formIvx.Substring(iwNz);
//Console.WriteLine(sub);
l1st.Add(sub);
iwNz += intVal;
}
You want something like this: 您想要这样的东西:
string input = Console.ReadLine();
int index = formFin.IndexOf(input);
if(index != -1)
{
var value = valueList[index];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.