base-class-library

Why doesn't the BCL have CRC classes?

牧云@^-^@ 提交于 2020-02-05 00:23:13
问题 Why doesn't the .NET Base Class Libary have CRC classes? 回答1: Eric Lippert has the best explanation of "Why Feature X is not implemented" (I think he knows a thing or two about why or why not things get implemented in the language) I am asked "why doesn't C# implement feature X?" all the time. The answer is always the same: because no one ever designed, specified, implemented, tested, documented and shipped that feature. All six of those things are necessary to make a feature happen. All of

Should one prefer ImmutableDictionary, or ImmutableSortedDictionary?

大兔子大兔子 提交于 2020-01-24 02:42:04
问题 I have heard that the .NET System.Collections.Immutable collections are implemented as balanced binary trees in order to satisfy their immutability constraints, even collections which traditionally model hash tables like Dictionary , by using the integral value of GetHashCode as a sort key. If I have a type for which it is cheap to generate a hash code, and for which is cheap to compare (e.g. string or int ), and I don't care about the sorted-ness of my collection, would it make sense to

System.Version doesn't implement System.IComparable in F#

醉酒当歌 提交于 2020-01-15 08:29:10
问题 I want to sort a sequence of Version objects in F#: let maxVersion = versions |> Seq.max (fun version -> version) The compiler produces the following error message: The type '(seq -> 'a)' does not support the 'comparison' constraint. For example, it does not support the 'System.IComparable' interface When I hit F12 in Visual studio to take a look at the metadata of Version it says that Version only implements ICloneable , but not IComparable . But when I go to sourceof.net it says it

When should I use a BitVector32?

寵の児 提交于 2020-01-13 10:26:27
问题 I am working on a project where at a certain moment I need to show for one month which days are still available. There is a function that calculates which days are available. My colleagues said:"Oh we know, you should return a BitVector32. That's the most efficient when working with a list of booleans." I would have used a List<bool> or something like that. A BitVector32 seems to me to be something for low level stuff when you are actually working with bits. So, the question is. Should you

What's the reason of using implicit/explicit convertions instead of constructors?

╄→尐↘猪︶ㄣ 提交于 2020-01-01 09:33:38
问题 An example would be: XNamespace ns = "my namespace" Why not?: XNamespace ns = new XNamespace ( "my namespace" ) What's the idea behind using implicit/explicit convertions instead of constructors? Convenience? Is there a guideline for this? 回答1: Convenience? More or less, yes. Consider the case for when you’ve got a number-like object (say, a Complex ) on which you do calculations. Clearly, writing code such as: Complex result = c1 * new Complex(2) + new Complex(32); is very annoying and hard

When does the UnderlyingSystemType differ from the current Type instance

Deadly 提交于 2020-01-01 01:17:54
问题 System.Type contains an UnderlyingSystemType property. MSDN states that it: Indicates the type provided by the common language runtime that represents this type. In most cases, this property simply returns the current Type instance. My question is, in what circumstances does this property not return the current Type instance itself. And in those cases, what sort of type will be the current Type instance and the returned underlying system type be? 回答1: To be honest I never did it by myself,

When does the UnderlyingSystemType differ from the current Type instance

怎甘沉沦 提交于 2020-01-01 01:17:15
问题 System.Type contains an UnderlyingSystemType property. MSDN states that it: Indicates the type provided by the common language runtime that represents this type. In most cases, this property simply returns the current Type instance. My question is, in what circumstances does this property not return the current Type instance itself. And in those cases, what sort of type will be the current Type instance and the returned underlying system type be? 回答1: To be honest I never did it by myself,

Exactly how large is the .NET (3.5) Framework Class Library?

て烟熏妆下的殇ゞ 提交于 2019-12-31 22:37:13
问题 I've regularly read that the framework is just too large for one developer to have experience with every part of it. Having some actual numbers would certainly help put things in perspective. MSDN seems to list them all but there are no actual numbers (from what I could see) and spending hours counting them is not my idea of productive time. Number of Namespaces Number of Classes Number of Structs Number of Interfaces I realize there are also delegates, enums, events, etc, but the above types