using System.Linq;
using UnityEngine;
public class DictionaryExample : MonoBehaviour
{
private Dictionary<int, string> myDictionary = new Dictionary<int, string>()
{
{1, "One"},
{2, "Two"},
{3, "Three"}
};
void Start()
{
KeyValuePair<int, string> lastElement = myDictionary.Last();
int lastKey = lastElement.Key;
string lastValue = lastElement.Value;
Debug.Log($"Last Key: {lastKey}, Last Value: {lastValue}");
}
}
unity 获取字典最后一位元素
最新推荐文章于 2025-05-16 14:56:23 发布