language-features

How is Nullable<T> different from a similar custom C# struct?

倖福魔咒の 提交于 2019-12-21 18:13:15
问题 In Nullable micro-optimizations, part one, Eric mentions that Nullable<T> has a strange boxing behaviour that could not be achieved by a similar user-defined type. What are the special features that the C# language grants to the predefined Nullable<T> type? Especially the ones that could not be made to work on a MyNullable type. Of course, Nullable<T> has special syntactic sugar T? , but my question is more about semantics. 回答1: What I was getting at is: there is no such thing as a boxed

How is Nullable<T> different from a similar custom C# struct?

你。 提交于 2019-12-21 18:13:06
问题 In Nullable micro-optimizations, part one, Eric mentions that Nullable<T> has a strange boxing behaviour that could not be achieved by a similar user-defined type. What are the special features that the C# language grants to the predefined Nullable<T> type? Especially the ones that could not be made to work on a MyNullable type. Of course, Nullable<T> has special syntactic sugar T? , but my question is more about semantics. 回答1: What I was getting at is: there is no such thing as a boxed

Java Language Specification - Cannot understand 'BlockStatement'

北城余情 提交于 2019-12-21 07:28:09
问题 I've been examining the Java Language Specification here (instead I should be out having a beer) and I am curious about what a method can contain. The specification states a method body can contain a block MethodBody: Block Where a 'Block' contains 'BlockStatements'. The 'BlockStatement' rule looks like this: BlockStatement : LocalVariableDeclarationStatement ClassOrInterfaceDeclaration [Identifier :] Statement I can understand the 'LocalVariableDeclarationStatement' which could be [final]

Python 3.0 - dict methods return views - why?

寵の児 提交于 2019-12-21 03:42:48
问题 dict methods dict.keys(), dict.items() and dict.values() return “views” instead of lists. http://docs.python.org/dev/3.0/whatsnew//3.0.html First of all how is a view different from an iterator? Secondly, what is the benefit of this change? Is it just for performance reasons? It doesn't seem intuitive to me, i.e., I'm asking for a list of thing (give me all your keys) and I'm getting something else back. Will this confuse people? 回答1: You are effectively getting a list. It's just not a copy

Auto translating website using Google Translate

不羁的心 提交于 2019-12-21 03:15:34
问题 I need to find a way to translate a website to the appropriate language as the locale settings on a users machine. So in otherwords someone from Germany visits my site, his locale settings are GErman, nou the site displays in German, is this possible to do using Google Translate or are there other options available? 回答1: I know that when I visit a site in another language using Google Chrome, it says "This site appears to be in [Drop Down With Languages]. Do you want Google to translate it?"

How to declare a C# Record Type?

断了今生、忘了曾经 提交于 2019-12-21 03:13:09
问题 I read on a blog that C# 7 will feature record types class studentInfo(string StudentFName, string StudentMName, string StudentLName); However when I tried it, I get these errors CS0116 A namespace cannot directly contain members such as fields or methods CS1022 Type or namespace definition, or end-of-file expected CS1514 { expected How is this supposed to work? 回答1: Record types are not (yet) implemented in C#. See the proposal in the official GitHub repository: https://github.com/dotnet

Question regarding implicit conversions in the C# language specification

孤街浪徒 提交于 2019-12-20 19:25:10
问题 Section 6.1 Implicit conversions defines an identity conversion thusly: An identity conversion converts from any type to the same type. This conversion exists such that an entity that already has a required type can be said to be convertible to that type. Now, what is the purpose of sentences such as these? (In §6.1.6 Implicit reference conversions) The implicit reference conversions are: [...] From any reference-type to a reference-type T if it has an implicit identity or reference

Question regarding implicit conversions in the C# language specification

余生颓废 提交于 2019-12-20 19:24:03
问题 Section 6.1 Implicit conversions defines an identity conversion thusly: An identity conversion converts from any type to the same type. This conversion exists such that an entity that already has a required type can be said to be convertible to that type. Now, what is the purpose of sentences such as these? (In §6.1.6 Implicit reference conversions) The implicit reference conversions are: [...] From any reference-type to a reference-type T if it has an implicit identity or reference

Should I use C++0x Features Now?

血红的双手。 提交于 2019-12-20 17:47:13
问题 With the official release of VS 2010, is it safe for me to start using the partially-implemented C++0x feature set in my new code? The features that are of interest to me right now are both implemented by VC++ 2010 and recent versions of GCC. These are the only two that I have to support. In terms of the "safety" mentioned in the first sentence: can I start using these features (e.g., lambda functions) and still be guaranteed that my code will compile in 10 years on a compiler that properly

Should I prefer static methods in C#

蹲街弑〆低调 提交于 2019-12-20 11:35:39
问题 Having spent a bit of time learning about functional programming, it's becoming more and more natural for me to want to work with static methods that don't perform any mutation. Are there any reasons why I should curb this instinct? 回答1: The question I find a bit odd, because static methods and methods that perform no mutations are two orthogonal classifications of methods. You can have mutating static methods and nonmutating instance methods. For me, it has become more and more natural to