This question already has an answer here: When should I use double instead of decimal? 12 answers For money, always decimal. It's why it was created. If numbers must add up correctly or balance, use decimal. This includes any financial storage or calculations, scores, or other numbers that people might do by hand. If the exact value of numbers is not important, use double for speed
这个问题在这里已经有了答案: 什么时候应该使用double而不是小数? 12个答案 对于金钱, 总是小数。 这就是它被创造的原因。 如果数字必须正确合计或平衡,请使用小数。 这包括任何财务存储或计算,分数或人们可能手动完成的其他数字。 如果数字的确切值不重要,请使用double来表示速度。 这包括图形,物理或其他物理科学计算,其中已经有“有效位数”。 我的问题是什么时候应该使用双精度型,什么时候应该使用小数
What is the difference between ref and out parameters in .NET? What are the situations where one can be more useful than the other? What would be a code snippet where one can be used and another can't? They're pretty much the same - the only difference is that a variable you pass as an out parameter doesn't need to be initialized but passing it as a ref parameter it has to be set
.NET中ref和out参数有什么区别? 什么情况下,一个人可以比另一个更有用? 什么是代码片段,其中一个可以使用,另一个不可以? 它们几乎相同 - 唯一的区别是你作为out参数传递的变量不需要被初始化,而是将它作为ref参数传递,它必须被设置为某个东西。 int x; Foo(out x); // OK int y; Foo(ref y); // Error: y should be initialized before calling the method Ref参数用于可能被修改的数据, out参数用于数据,该数
如何在运行代码的计算机上安装不需要Excel的情况下如何使用C#创建Excel电子表格? You can use a library called ExcelLibrary. It's a free, open source library posted on Google Code: ExcelLibrary This looks to be a port of the PHP ExcelWriter that you mentioned above. It will not write to the new .xlsx format yet, but they are working on adding that functionality in. It's very simple, s
如何在运行代码的计算机上安装不需要Excel的情况下如何使用C#创建Excel电子表格? 您可以使用名为ExcelLibrary的库。 这是一个免费的,在Google Code上发布的开源库: ExcelLibrary 这看起来是上面提到的PHP ExcelWriter的一个端口。 它不会写入新的.xlsx格式,但他们正在努力添加该功能。 它非常简单,小巧易用。 另外它有一个DataSetHelper,可以让你使用DataSets和DataTables轻松处理Excel数据。 ExcelLibrary似
What is the difference between returning IQueryable<T> vs. IEnumerable<T> ? IQueryable<Customer> custs = from c in db.Customers where c.City == "<City>" select c; IEnumerable<Customer> custs = from c in db.Customers where c.City == "<City>" select c; Will both be deferred execution and when should one be preferred over the other? Yes, both will give you de
返回IQueryable<T>与IEnumerable<T>什么区别? IQueryable<Customer> custs = from c in db.Customers where c.City == "<City>" select c; IEnumerable<Customer> custs = from c in db.Customers where c.City == "<City>" select c; 双方都会被推迟执行,并且什么时候应该比另一方优先? 是的,两者都会让你延期执行。 不同之处在于IQueryable<T>是允许LINQ到SQL(LINQ到任
All my college years I have been using public , and would like to know the difference between public , private , and protected ? Also what does static do as opposed to having nothing? Access modifiers public The type or member can be accessed by any other code in the same assembly or another assembly that references it. private The type or member can only be accessed by code in the sa
我一直在使用public课的大学时间,想知道public , private和protected之间的区别吗? 还有什么是static ,而不是什么都没有? 访问修饰符 上市 类型或成员可以被同一程序集或引用它的其他程序集中的任何其他代码访问。 私人的 类型或成员只能由同一类或结构中的代码访问。 保护 类型或成员只能由同一个类或结构中的代码或派生类中的代码访问。 内部 类型或成员可以由同一个程序集中的任何代码访问,但不能
like in java I have: Class.getSuperClass().getDeclaredFields() how I can know and set private field from a superclass? I know this is strongly not recommended, but I am testing my application and I need simulate a wrong situation where the id is correct and the name not. But this Id is private. Yes, it is possible to use reflection to set the value of a readonly field after the constructor
像在java中我有: Class.getSuperClass().getDeclaredFields() 我如何才能从超类中知道并设置私人领域? 我知道这是强烈不建议,但我正在测试我的应用程序,我需要模拟错误的情况下,ID是正确的,名称不正确。 但是这个ID是私人的。 是的,可以在构造函数运行后使用反射来设置只读字段的值 var fi = this.GetType() .BaseType .GetField("_someField", BindingFlags.Instance | BindingFlags.N
Possible Duplicate: What's the difference between String and string? When does it matter whether you use int versus Int32, or string versus String? in visual studio when i am typing string,it shows two suggestions as is both 'string' and 'String' same? Visual studio shows the same description for both. so if they are same what is the need for keeping two different t
可能重复: 字符串和字符串有什么区别? 什么时候使用int还是Int32还是string与String? 在visual studio中,当我输入字符串时,它显示两个建议 'string'和'String'是相同的吗? Visual Studio为两者显示相同的描述。 所以如果它们是相同的,那么保持执行相同功能的两个不同事物的需求是什么? 正如这篇文章所证实的那样,在技术上与你使用它没有任何区别。 如答案中所述,如果使用string ,则认
This question already has an answer here: What is the difference between bool and Boolean types in C# 15 answers What is the difference between String and string in C#? 59 answers They are the same. If you mouse over the lowercase one it shows that it is an alias to the uppercase version. Note that by convention you should always use the lowercase version bool is an alias for System.B
这个问题在这里已经有了答案: C#15答案中bool和布尔类型有什么区别 String和C#中的字符串有什么区别? 59个答案 他们是一样的。 如果将鼠标悬停在小写字母之上,则表明它是大写版本的别名。 请注意,按照惯例,您应始终使用小写版本 bool是System.Boolean的别名,其中double是System.Double的别名, int是System.Int32的别名 它们都基本相同。
Possible Duplicate: What's the difference between String and string? I have been some time working with C# and i have ever noticed any diference between both types. String myStringAsClass; string myStringAsStruct; Is there any diference other than the clarification you may use on the code or convetion to use the static functions from String class and declarations from string struct? T
可能重复: 字符串和字符串有什么区别? 我有一段时间与C#一起工作,我发现两种类型之间都有差异。 String myStringAsClass; string myStringAsStruct; 除了您可能在代码或汇编上使用来自String类的静态函数和来自字符串struct的声明的澄清之外,是否还有其他不同之处? 非常感谢你! 他们是一样的。 它们都是参考类型。 System.String == string System.Object == object System.Int32 == int System.Int64 == long
This question already has an answer here: What is the difference between String and string in C#? 59 answers What is 'long?' data type? 6 answers There is no difference in the compiled code. They are aliases for the same thing. here is something more strange: Convert.ToInt64(27.5) = 28 (int64)27.5 = 27 I think, the difference is at cast and convert level rather than at data
这个问题在这里已经有了答案: String和C#中的字符串有什么区别? 59个答案 什么是“长”? 数据类型? 6个答案 编译后的代码没有区别。 他们是同一事物的别名。 这里更奇怪的是: Convert.ToInt64(27.5) = 28 (int64)27.5 = 27 我认为,区别在于转换级别而不是数据类型级别。