草庐IT

current_round

全部标签

c# - 为什么 Math.Round/Floor/Ceiling 不返回 long 或 int?

每次我使用Math.Round/Floor/Ceiling时我总是转换为int(或者可能是long如有必要)。如果它总是返回一个整数,为什么他们返回double。 最佳答案 结果可能不适合int(或long)。double的范围要大得多。double的近似范围:±5.0×10−324到±1.7×10308(Source) 关于c#-为什么Math.Round/Floor/Ceiling不返回long或int?,我们在StackOverflow上找到一个类似的问题:

c# - 为什么 Math.Round/Floor/Ceiling 不返回 long 或 int?

每次我使用Math.Round/Floor/Ceiling时我总是转换为int(或者可能是long如有必要)。如果它总是返回一个整数,为什么他们返回double。 最佳答案 结果可能不适合int(或long)。double的范围要大得多。double的近似范围:±5.0×10−324到±1.7×10308(Source) 关于c#-为什么Math.Round/Floor/Ceiling不返回long或int?,我们在StackOverflow上找到一个类似的问题:

c# - 错误 : The Out Parameter must be assigned before control leaves the current method

发送回参数时出现此错误Error:TheOutParametermustbeassignedbeforecontrolleavesthecurrentmethod代码是publicvoidGetPapers(stringweb,outintId1,outintId2){SqlConnectionconn=newSqlConnection(ConnectionString());conn.Open();SqlCommandcmd=newSqlCommand("GetPapers",conn);cmd.CommandType=CommandType.StoredProcedure;cmd.

c# - 错误 : The Out Parameter must be assigned before control leaves the current method

发送回参数时出现此错误Error:TheOutParametermustbeassignedbeforecontrolleavesthecurrentmethod代码是publicvoidGetPapers(stringweb,outintId1,outintId2){SqlConnectionconn=newSqlConnection(ConnectionString());conn.Open();SqlCommandcmd=newSqlCommand("GetPapers",conn);cmd.CommandType=CommandType.StoredProcedure;cmd.

c# - 为什么 .NET 在 String.Format 中使用与默认 Math.Round() 算法不一致的舍入算法?

我注意到C#/.NET中存在以下不一致之处。为什么会这样?Console.WriteLine("{0,-4:#.0}|{1,-4:#.0}",1.04,Math.Round(1.04,1));Console.WriteLine("{0,-4:#.0}|{1,-4:#.0}",1.05,Math.Round(1.05,1));Console.WriteLine("{0,-4:#.0}|{1,-4:#.0}",1.06,Math.Round(1.06,1));Console.WriteLine("{0,-4:#.0}|{1,-4:#.0}",1.14,Math.Round(1.14,1))

c# - 为什么 .NET 在 String.Format 中使用与默认 Math.Round() 算法不一致的舍入算法?

我注意到C#/.NET中存在以下不一致之处。为什么会这样?Console.WriteLine("{0,-4:#.0}|{1,-4:#.0}",1.04,Math.Round(1.04,1));Console.WriteLine("{0,-4:#.0}|{1,-4:#.0}",1.05,Math.Round(1.05,1));Console.WriteLine("{0,-4:#.0}|{1,-4:#.0}",1.06,Math.Round(1.06,1));Console.WriteLine("{0,-4:#.0}|{1,-4:#.0}",1.14,Math.Round(1.14,1))

c# - 为什么 IEnumerator.Current 的错误处理不同于 IEnumerator<T>.Current?

我原以为对实现了IEnumerable的空集合执行以下代码会抛出异常:varenumerator=collection.GetEnumerator();enumerator.MoveNext();vartype=enumerator.Current.GetType();//Surelyshouldthrow?因为集合是空的,然后访问IEnumerator.Current无效,我本以为会有异常(exception)。但是,List不会抛出异常.这是thedocumentationforIEnumerator.Current允许的,其中指出Current在以下任何条件下未定义:枚举数位于集

c# - 为什么 IEnumerator.Current 的错误处理不同于 IEnumerator<T>.Current?

我原以为对实现了IEnumerable的空集合执行以下代码会抛出异常:varenumerator=collection.GetEnumerator();enumerator.MoveNext();vartype=enumerator.Current.GetType();//Surelyshouldthrow?因为集合是空的,然后访问IEnumerator.Current无效,我本以为会有异常(exception)。但是,List不会抛出异常.这是thedocumentationforIEnumerator.Current允许的,其中指出Current在以下任何条件下未定义:枚举数位于集

c# - 如果我不注意警告 "hides inherited member. To make the current member override that implementation...."怎么办

这可能是一个很好的观点,但它涉及编译器发出的警告,如果您执行以下操作:classA{publicvirtualvoidF(){}}classB:A{publicvoidF(){}}然后你会得到警告:'EomApp1.B.F()'hidesinheritedmember'EomApp1.A.F()'.Tomakethecurrentmemberoverridethatimplementation,addtheoverridekeyword.Otherwiseusethenewkeyword.问题:如果我不采取任何措施,实际警告我的警告是什么?如果我添加“new”关键字与不添加关键字,我的

c# - 如果我不注意警告 "hides inherited member. To make the current member override that implementation...."怎么办

这可能是一个很好的观点,但它涉及编译器发出的警告,如果您执行以下操作:classA{publicvirtualvoidF(){}}classB:A{publicvoidF(){}}然后你会得到警告:'EomApp1.B.F()'hidesinheritedmember'EomApp1.A.F()'.Tomakethecurrentmemberoverridethatimplementation,addtheoverridekeyword.Otherwiseusethenewkeyword.问题:如果我不采取任何措施,实际警告我的警告是什么?如果我添加“new”关键字与不添加关键字,我的