int n = 5;
int quorum = Math.Floor(n / 2) + 1;
Run Code Online (Sandbox Code Playgroud)
我期望法定人数具有值3.但这是我在VisualStudio中得到的错误:
以下方法或属性之间的调用不明确:'System.Math.Floor(double)'和'System.Math.Floor(decimal)'
我该如何纠正?我哪里做错了?
我的代码做的很简单
列表已经有元素.我在列表中有大约25000个元素(我希望有更多元素),每个元素都很小(DateTime).
List<DateTime> newList = new List<DateTime>();
Parallel.ForEach(list, l => newlist.Add(new DateTime(l.Ticks + 5000)));
Run Code Online (Sandbox Code Playgroud)
也就是说,基于每个元素,我正在创建新元素并将它们添加到不同的列表中.但是,这似乎不是一个好的编程方法.我打这个例外一些时间,但不是每次.
IndexOutOfRangeException : {"Index was outside the bounds of the array."}
Run Code Online (Sandbox Code Playgroud)
我们可以使用Parallel.ForEach()将元素添加到列表中吗?如果是,为什么我会遇到错误?如果不是,为什么?