先在List內找到符合條件的該筆資料Index,再用Index去調出要尋找的該筆資料其他部分:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class MainProcess : MonoBehaviour {
private List<tempStructure> tempStructureList = new List<tempStructure>();
private struct tempStructure
{
public int tempNumber;
public string tempName;
}
void Start ()
{
tempStructure xxx = new tempStructure();
tempStructure yyy = new tempStructure();
xxx.tempNumber = 1;
xxx.tempName = "XXX";
yyy.tempNumber = 2;
yyy.tempName = "YYY";
tempStructureList.Add( xxx );
tempStructureList.Add( yyy );
tempIndex = tempStructureList.FindIndex( z => z.tempName == "XXX" );
Debug.log( tempStructureList[tempIndex].tempNumber );
}
}
沒有留言:
張貼留言