user3410566
user3410566

Reputation: 45

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.

One of them is filled with currency ISO codes. Second is their value. Both lists have 332 lines.

I want to compare a Console.ReadLine(); input with the currency ISO codes list.

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;

}

Upvotes: 0

Views: 86

Answers (1)

Selman Gen&#231;
Selman Gen&#231;

Reputation: 101681

You want something like this:

string input = Console.ReadLine();

int index = formFin.IndexOf(input);

if(index != -1)
{
     var value = valueList[index];
}

Upvotes: 1

Related Questions