C# linq获取数组元素查询

C# linq获取数组元素查询,c#,linq,lambda,C#,Linq,Lambda,我只想用我的字典中的元素创建一个数组,这些元素的值等于零 Dictionary<string, int> dict = new Dictionary<string, int>(); int notZeroValues = dict.Values.ToArray(); //sth here to get these elements efficiently Dictionary dict=new Dictionary(); int notZeroValues=dict.

我只想用我的
字典
中的元素创建一个
数组
,这些元素的值等于零

Dictionary<string, int> dict = new Dictionary<string, int>();
int notZeroValues = dict.Values.ToArray();  //sth here to get these elements efficiently
Dictionary dict=new Dictionary();
int notZeroValues=dict.Values.ToArray()//这里的sth可以有效地获取这些元素
请帮忙

dict.Where(x => x.Value != 0).Select(x => x.Value).ToArray();
另一种方式:

dict.Values.OfType<int>().Where(x => x != 0).ToArray();
dict.Values.OfType()。其中(x=>x!=0.ToArray();

这是打字错误吗?你是说数值不等于零?