C# 数组转List
2018-02-24 本文已影响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)");
}