bcl

How did Microsoft create assemblies that have circular references?

In the .NET BCL there are circular references between: System.dll and System.Xml.dll System.dll and System.Configuration.dll System.Xml.dll and System.Configuration.dll Here's a screenshot from .NET Reflector that shows what I mean: How Microsoft created these assemblies is a mystery to me. Is a special compilation process requir...

What is the reason for IEnumerable/IEnumerable<T> interfaces to only have MoveNext?

Basically I am wondering why MS decided to implement an enumerator that only supports going forward: MoveNext(). Is it not more flexible to also enforce MovePrevious for this widely used interface throughout the .NET framework? I can imagine it making the Linq.Reverse far easier to implement for MS and more efficient in performance, bu...

Is Environment.TickCount affected by system time adjustments?

I'm curious as to how the .NET BCL property Environment.TickCount is implemented. In particular I'd like to now if it is affected by system time adjustments. My first guess as to how the property was implemented was that it was simply a managed wrapper around the GetTickCount method. However, the documentation for the GetTickCount metho...

Good books for the .NET 3.5 BCL?

I'm looking for a good book that covers the .NET 3.5 base class library, using C# as the language. I'm going to be bringing my team up to speed on .NET in general, and I'd like to use the book as a sort of curriculum for my sessions. I don't want something that teaches the language (C#) itself, but rather the base class library (the fram...

How to represent countries and languages in C#?

I will retrieve this data from an xml to initialize it for thousands of objects. So if MyObject has a Country and Language property, what should they be, and how should they be represented both in code and in xml. I am thinking of using an Enum in code. I am just looking for other people's opinions to find the best way to do this. Is ...

How to create multiple directories from a single full path in C#?

If you have a full path like: "C:\dir0\dir1\dir2\dir3\dir4\" how would you best implement it so that all directories are present? Is there a method for this in the BCL? If not, what's the most elegant way to do this? ...

Is there a "Number" struct/class in .NET?

I am attempting to store a variable length number that can have leading zeros as a part of that number. Is there a class in the .NET framework capable of storing values like this without losing information about leading zeros, and could surpass the upper limit of a long? I am currently storing them in a class like this, is there any wa...

Go To Statement Considered Harmful?

If the statement above is correct, then why when I use reflector on .Net BCL I see it is used a lot? EDIT: let me rephrase: are all the GO-TO's I see in reflector written by humans or compilers? ...

Why does not IDictionary (non-generic) inherit from IEnumerable<DictionaryEntry>?

IDictionary<TKey, TValue> inherits from IEnumerable<KeyValuePair<TKey, TValue>>, but IDictionary for some reason doesn't inherit from IEnumerable<DictionaryEntry>. I wonder why? I hate to write this ugly .OfType<DictionaryEntry>() every time when I need to make a query against an IDictionary. ...

What is the maximum amount of characters or length for a Directory?

What is the maximum amount of characters that a typical path can contain for a directory when using C#? For example C:\test\ has 7 characters in length , what is the maximum length? ...

Efficient, Immutable, Extensible Collections for .NET

It seems to me there is an extreme lack of safe, immutable collection types for .NET, in particular BCL but I've not seen much work done outside either. Do anyone have any pointers to a (preferably) production quality, fast, immutable collections library for .NET. A fast list type is essential. I'm not yet prepared to switch to F#. ...

Why is there no Char.Empty like String.Empty?

Is there a reason for this? I am asking this because if you needed to use lots of empty char, then you get into the same situation as you would when you use lots of empty strings. EDIT: Reason for this usage was this: myString.Replace ('c', '') So remove all instances of 'c's from myString. ...

Would .NET be able to function just as well without the use of type Object?

I am asking this because it seems like using Object seems to be an easy way out to solve certain problems, like "I don't have a specific type, so use Object", etc. Also the reason this made me curious is because a colleague of mine told me that if .NET was a true object-oriented platform then it wouldn't have to have a catch all type li...

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

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? ...

Why we use flush parameter with Encoder.GetBytes method

This link explains the Encoder.GetBytes Method and there is a bool parameter called flush explained too . The explanation of flush is : true if this encoder can flush its state at the end of the conversion; otherwise, false. To ensure correct termination of a sequence of blocks of encoded bytes, the last call to GetBytes ca...

Bug in Directory.GetParent ?

I was hit in the face by a very weird behavior of the System.IO.Directory.GetParent method: string path1 = @"C:\foo\bar"; DirectoryInfo parent1 = Directory.GetParent(path1); Console.WriteLine (parent1.FullName); // Prints C:\foo, as expected // Notice the extra backslash. It should still refer to the same location, right ? string path2...