Questions tagged [base-class-library]

The .NET Framework Base Class Library (BCL) is a library of classes, interfaces, and value types that provides access to system functionality and is designed to be the foundation on which .NET Framework applications, components, and controls are built.

The Microsoft .NET Framework base class library (BCL) is a library of classes, interfaces, and value types that provides access to system functionality and is designed to be the foundation on which .NET Framework applications, components, and controls are built.

These libraries are available to all languages which run on .NET.

193 questions
338
votes
14 answers

What is C# analog of C++ std::pair?

I'm interested: What is C#'s analog of std::pair in C++? I found System.Web.UI.Pair class, but I'd prefer something template-based. Thank you!
Alexander Prokofyev
  • 33,874
  • 33
  • 95
  • 118
316
votes
23 answers

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

Is there a reason for this? I am asking because if you needed to use lots of empty chars then you get into the same situation as you would when you use lots of empty strings. Edit: The reason for this usage was this: myString.Replace ('c', '') So…
Joan Venge
  • 315,713
  • 212
  • 479
  • 689
189
votes
2 answers

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?
Joan Venge
  • 315,713
  • 212
  • 479
  • 689
110
votes
9 answers

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…
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
63
votes
2 answers

Why do BCL Collections use struct enumerators, not classes?

We all know mutable structs are evil in general. I'm also pretty sure that because IEnumerable.GetEnumerator() returns type IEnumerator, the structs are immediately boxed into a reference type, costing more than if they were simply reference…
Eloff
  • 20,828
  • 17
  • 83
  • 112
54
votes
2 answers

Why is a "bindingRedirect" added to the app.config file after adding the Microsoft.Bcl.Async package?

I was wondering why nuget added the following code to my applications app.config file, after installing the Microsoft.Bcl.Async:
GameScripting
  • 16,092
  • 13
  • 59
  • 98
48
votes
7 answers

Why is a Dictionary "not ordered"?

I have read this in answer to many questions on here. But what exactly does it mean? var test = new Dictionary(); test.Add(0, "zero"); test.Add(1, "one"); test.Add(2, "two"); test.Add(3, "three"); Assert(test.ElementAt(2).Value ==…
fearofawhackplanet
  • 52,166
  • 53
  • 160
  • 253
48
votes
7 answers

Why does List implement IReadOnlyList in .NET 4.5?

Why does List implement IReadOnlyList in .NET 4.5? List isn't read only...
James Newton-King
  • 48,174
  • 24
  • 109
  • 130
47
votes
4 answers

How can I convert BitArray to single int?

How can I convert BitArray to a single int?
Vlad Omelyanchuk
  • 3,021
  • 7
  • 29
  • 35
44
votes
9 answers

Convert from BitArray to Byte

I have a BitArray with the length of 8, and I need a function to convert it to a byte. How to do it? Specifically, I need a correct function of ConvertToByte: BitArray bit = new BitArray(new bool[] { false, false, false, false, false, false,…
Graviton
  • 81,782
  • 146
  • 424
  • 602
41
votes
3 answers

Why no AutoResetEventSlim in BCL?

Why isn't there an AutoResetEventSlim class in BCL? Can it be simulated using ManualResetEventSlim?
user629926
  • 1,910
  • 2
  • 18
  • 43
40
votes
1 answer

The current status of System.Net.Http vs. Microsoft.Net.Http

I am confused with packaging of HttpClient. Earlier it was distributed as a part of Microsoft.Http.Net NuGet package while System.Net.Http was considered legacy. Looks like now it's the opposite: there is a fresh System.Net.Http package for all…
Vagif Abilov
  • 9,835
  • 8
  • 55
  • 100
38
votes
6 answers

Why is there no SortedList in .NET?

Why is there only a SortedList which looks more like a dictionary, but no SortedList that is actually just a list that is always sorted? According to the MSDN documentation on SortedList, it is actually internally implemented as a…
Timwi
  • 65,159
  • 33
  • 165
  • 230
36
votes
5 answers

Why does TimeSpan.FromSeconds(double) round to milliseconds?

TimeSpan.FromSeconds takes a double, and can represent values down to 100 nanoseconds, however this method inexplicably rounds the time to whole milliseconds. Given that I've just spent half an hour to pinpoint this (documented!) behaviour, knowing…
Roman Starkov
  • 59,298
  • 38
  • 251
  • 324
35
votes
2 answers

Meaning of confusing comment above "string.Empty" in .NET/BCL source?

I'm trying to understand why string.Empty is readonly and not a const. I saw this Post but I don't understand the comment Microsoft wrote about it. As Jon Skeet wrote in a comment "I don't know - it doesn't make much sense to me, to be…
gdoron
  • 147,333
  • 58
  • 291
  • 367
1
2 3
12 13