简体   繁体   English

C#我有两个列表。 我想比较一下

[英]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.

相关问题 我想在两个列表之间应用除外。 一个列表是MailAddress格式,另一个是String(转换为列表)) - I want to apply Except between two lists. One list is in MailAddress format and other is a String (Converted to list)) 如何比较两个列表并在c#中找到不匹配的列表? - How to compare two lists and find the mismatch them in c#? 我如何从2个下拉列表中获取值并将其作为C#中的日期进行比较 - How can i get values from 2 dropdown lists and compare them as a date in C# C#比较两个列表 - C# Compare two Lists 我想合并 c# 中的排序列表 - i want to Merge a sorted lists in c# 如何有效地比较C#中两个大型对象列表的属性? - How can I efficiently compare the properties of two large lists of objects in C#? 给定两个对象列表,如何在C#中比较新的KV? - Given two lists of objects, how do I compare into new KV in C#? 如何比较两个列表并使用C#相应地设置像素值? - How can I compare two Lists against each other and set the pixels values accordingly using C#? C# 如何比较 Equals() 方法中的两个对象列表 - C# How can I compare two lists of objects in the Equals()-Method C#Linq - 给出两个列表,如何判断它们中是否包含其中一个 - C# Linq - Given two lists, how do I tell if either of them are contained in each other
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM