Unity using System.Linq namespace (continuously updated)

All() Whether all elements in the array meet the condition.

int[] numbers1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };

var bl = numbers1.All(val => val > 10);

Debug.Log(bl); //returns false

 Any() determines whether the list contains any elements.

List<int> list = new List<int>(); //No elements
        var v=list.Any();
        Debug.Log(v); // //Returns false

List<int> list = new List<int>() { 1,2,3 };
        var v=list.Any(i=>i%2==0); //Query whether there is any item in the list that is divisible by 2 Element
        Debug.Log(v); //returns true

Select() performs collection type conversion

public Transform[] tf;
        //Convert Transform[] array to Vetor3[] array
        var positions = tf.Select(u => u.position).ToArray(); 

Guess you like

Origin blog.csdn.net/m0_71624363/article/details/132126368