- Home /
Duplicate Question
Comparing int from list1 to int from list2
Hi guys im sorry im asking this question twice. It's because my last question wasnt really answered.
this is just for my learning purpuses and not for my game so i'll be happy to hear any answers
I have two list
List 1
[System.Serializable]
public class List1
{
public int List1int;
public string List1name;
public Texture2d List1texture,
}
List 2
[System.Serializable]
public class List2
{
public int List2int;
public string List2name;
public Texture2d List2texture,
}
Both of this list are in different scripts
So the question is how do i compare the list1int to the list2int.
For example:
If (list1int ==lis2int)
{
//do something
}
But this is not possible because it is not recognise by the script. I also tried the suggestions in my last question like
List1 list1Object = new List1();
List2 list2Object = new List2();
Which was said to work but it still does not recognise it. How would i make it so that it can recognise the list1int and then i can compare list1int to list2int.
*if possible can someone please give me a working script as an example of this scenario(each list in 2 different script)
Thanks,so greatful for any answers.
Go back and watch the beginner tutorials. You've asked this question three times today. It been answered, but your understanding of basic coding is so poor you haven't understood any of the answers.
You don't have 2 lists, you have 2 classes with 3 public fields each. Doing
if (list1int == list2int)
in class List1, for instance, doesn't work because List1 has no clue what list2int is. As Bored$$anonymous$$ormon pointed out, this is very basic coding. Asking more questions here won't get you anywhere, you need to sit down and study the basics for yourself to understand it.