framework-design

Why are Array.Sort() and Array.IndexOf() methods static?

坚强是说给别人听的谎言 提交于 2019-12-30 09:32:53
问题 Always was interested why are Array.Sort() and Array.IndexOf() methods made static and similar ArrayList.Sort() and ArrayList.IndexOf() are designed as member methods. Thank you for any ideas. 回答1: In my view Array class is basically a class representation of the fixed size arrays that we declare using [] in program (you can draw the analogy like int has it's class (structure) representation as System.Int32). Also Array class does not contain the actually array data in any instance variables

Why are Array.Sort() and Array.IndexOf() methods static?

拜拜、爱过 提交于 2019-12-30 09:32:25
问题 Always was interested why are Array.Sort() and Array.IndexOf() methods made static and similar ArrayList.Sort() and ArrayList.IndexOf() are designed as member methods. Thank you for any ideas. 回答1: In my view Array class is basically a class representation of the fixed size arrays that we declare using [] in program (you can draw the analogy like int has it's class (structure) representation as System.Int32). Also Array class does not contain the actually array data in any instance variables

What's the point of MethodImplOptions.InternalCall?

ε祈祈猫儿з 提交于 2019-12-17 23:16:43
问题 Many methods in the BCL are marked with the [MethodImpl(MethodImplOptions.InternalCall)] attribute. This indicates that the "method is implemented within the common language runtime itself". What was the point of designing the framework in this way over having specified explicit CIL instructions that the runtime would be forced to implement? Ultimately, the attribute is creating contractual obligations for the runtime, but in a way that appears to me to be confusing and not immediately

ReSharper complains about uppercase “ID” in member “EntityID”

喜欢而已 提交于 2019-12-09 05:04:07
问题 I have a property "EntityID" in a class. Resharper (5.1) says Name 'EntityID' does not match rule 'Methods, properties and events'. Suggested name is 'EntityId'. But IMHO according to the naming conventions in the Design Guidelines for Class Library Developers. 'EntityID' should be perfectly fine: Do not use acronyms that are not generally accepted in the computing field. Where appropriate, use well-known acronyms to replace lengthy phrase names. For example, use UI for User Interface and

What's the point of MethodImplOptions.InternalCall?

感情迁移 提交于 2019-11-28 21:09:33
Many methods in the BCL are marked with the [MethodImpl(MethodImplOptions.InternalCall)] attribute. This indicates that the "method is implemented within the common language runtime itself". What was the point of designing the framework in this way over having specified explicit CIL instructions that the runtime would be forced to implement? Ultimately, the attribute is creating contractual obligations for the runtime, but in a way that appears to me to be confusing and not immediately obvious. For example, Math.Pow could have been written this way (excuse my informal mixture of C# + IL and