美文网首页
C# 数组转List

C# 数组转List

作者: 杨树叶的杨 | 来源:发表于2018-02-24 14:11 被阅读0次
            string[] decorations = new string[]{"ring","roof","spTr","wall","lowerSphere" };
            List<string> decList = decorations.OfType<string> ().ToList ();
            Debug.Log ("decList.Count: " + decList.Count);
            foreach (string name in decList)
            {
                Debug.Log (name);
            }
    
            List<string> decList2 = decorations.ToList<string> ();
            Debug.Log ("decList2.Count: " + decList2.Count);
            foreach (string name in decList2)
            {
                Debug.Log (name);
            }
    
            List<string> List03 = new List<string> (decorations);
            Debug.Log ("List03.Count: " + List03.Count);
            foreach (string name in List03)
            {
                Debug.Log (name);
            }
    
            List<string> List04 = new List<string> ();
            List04.AddRange (decorations);
            Debug.Log ("List04.Count: " + List04.Count);
            foreach (string name in List04)
            {
                Debug.Log (name);
            }
    
            if (decList2 == decList)
            {
                Debug.Log ("decList2 == decList");
            }
            else
            {
                Debug.Log ("decList2 != decList");
            }
    
            if (decList.All(decList2.Contains) && decList.Count == decList2.Count)
            {
                Debug.Log ("decList.Equals (decList2)");
            }
            else
            {
                Debug.Log ("decList. not Equals (decList2)");
            }

    相关文章

      网友评论

          本文标题:C# 数组转List

          本文链接:https://www.haomeiwen.com/subject/crvqxftx.html