本文整理汇总了C#中Keys.Distinct方法的典型用法代码示例。如果您正苦于以下问题:C# Keys.Distinct方法的具体用法?C# Keys.Distinct怎么用?C# Keys.Distinct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Keys
的用法示例。
在下文中一共展示了Keys.Distinct方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetListenKeys
//Set a custom list of keys to choose from, if no custom list is given, listen to all keys
/// <summary>
/// Set what keys to return if pressed. If no keys are set, all keys will be listened to.
/// </summary>
/// <param name="ListenKeys">A list of Xna.Framework.Input.Keys that holds a group of non-duplicated keys to return if pressed</param>
public void SetListenKeys(Keys[] ListenKeys)
{
if (ListenKeys.Count() == ListenKeys.Distinct<Keys>().Count()) //Checks for duplicates
{
foreach (Keys Key in ListenKeys)
{
listen_keys.Add(new Keystroke(Key, 0));
}
}
else
{
throw new System.ArgumentException("Argument has duplicates", "ListenKeys"); //Duplicates will cause problems to happen with the key buffer.
}
}