ProblemBook.NET
Return to book
Review this book
About the author
Introduction
1. Introduction
2. OOP (Problems) 2.1. OverloadResolutionBasic 2.2. OverloadResolutionOverride 2.3. OverloadResolutionInheritance 2.4. InheritanceNestedClass 2.5. StaticFieldInGenericType
2.1. OverloadResolutionBasic
2.2. OverloadResolutionOverride
2.3. OverloadResolutionInheritance
2.4. InheritanceNestedClass
2.5. StaticFieldInGenericType
3. LINQ (Problems) 3.1. EnumerableToArray 3.2. LifeAfterYield 3.3. ClosureAndForeach 3.4. ClosureAndFor 3.5. QueryAfterRemove 3.6. ClosureAndVariable 3.7. QueryWithInc 3.8. ExceptionYieldYield 3.9. YieldExceptionYield 3.10. TryYieldFinally
3.1. EnumerableToArray
3.2. LifeAfterYield
3.3. ClosureAndForeach
3.4. ClosureAndFor
3.5. QueryAfterRemove
3.6. ClosureAndVariable
3.7. QueryWithInc
3.8. ExceptionYieldYield
3.9. YieldExceptionYield
3.10. TryYieldFinally
4. Mathematics (Problems) 4.1. Rounding1 4.2. Rounding2 4.3. Eps 4.4. DivideByZero 4.5. Overflow 4.6. AugmentedAssignment 4.7. DynamicIncrement
4.1. Rounding1
4.2. Rounding2
4.3. Eps
4.4. DivideByZero
4.5. Overflow
4.6. AugmentedAssignment
4.7. DynamicIncrement
5. Value types (Problems) 5.1. Boxing 5.2. MutableProperty 5.3. Enumerator 5.4. StructLayout
5.1. Boxing
5.2. MutableProperty
5.3. Enumerator
5.4. StructLayout
6. Strings (Problems) 6.1. PlusString 6.2. PlusChar 6.3. StringPlusNull 6.4. CaseInComparison 6.5. CorruptedNumber 6.6. CurrentCulture 6.7. CompareToVsEquals 6.8. CorruptedString 6.9. ExplicitlyInternment 6.10. NoStringInterning 6.11. InternmentAndMetadata 6.12. Secure 6.13. StableSorting 6.14. TextElementEnumerator
6.1. PlusString
6.2. PlusChar
6.3. StringPlusNull
6.4. CaseInComparison
6.5. CorruptedNumber
6.6. CurrentCulture
6.7. CompareToVsEquals
6.8. CorruptedString
6.9. ExplicitlyInternment
6.10. NoStringInterning
6.11. InternmentAndMetadata
6.12. Secure
6.13. StableSorting
6.14. TextElementEnumerator
7. Multithreading (Problems) 7.1. ThreadStaticVariable 7.2. LockSlimInFinalizer
7.1. ThreadStaticVariable
7.2. LockSlimInFinalizer
8. OOP (Solutions) 8.1. OverloadResolutionBasic 8.2. OverloadResolutionOverride 8.3. OverloadResolutionInheritance 8.4. InheritanceNestedClass 8.5. StaticFieldInGenericType
8.1. OverloadResolutionBasic
8.2. OverloadResolutionOverride
8.3. OverloadResolutionInheritance
8.4. InheritanceNestedClass
8.5. StaticFieldInGenericType
9. LINQ (Solutions) 9.1. EnumerableToArray 9.2. LifeAfterYield 9.3. ClosureAndForeach 9.4. ClosureAndFor 9.5. QueryAfterRemove 9.6. ClosureAndVariable 9.7. QueryWithInc 9.8. ExceptionYieldYield 9.9. YieldExceptionYield 9.10. TryYieldFinally
9.1. EnumerableToArray
9.2. LifeAfterYield
9.3. ClosureAndForeach
9.4. ClosureAndFor
9.5. QueryAfterRemove
9.6. ClosureAndVariable
9.7. QueryWithInc
9.8. ExceptionYieldYield
9.9. YieldExceptionYield
9.10. TryYieldFinally
10. Mathematics (Solutions) 10.1. Rounding1 10.2. Rounding2 10.3. Eps 10.4. DivideByZero 10.5. Overflow 10.6. AugmentedAssignment 10.7. DynamicIncrement
10.1. Rounding1
10.2. Rounding2
10.3. Eps
10.4. DivideByZero
10.5. Overflow
10.6. AugmentedAssignment
10.7. DynamicIncrement
11. Value types (Solutions) 11.1. Boxing 11.2. MutableProperty 11.3. Enumerator 11.4. StructLayout
11.1. Boxing
11.2. MutableProperty
11.3. Enumerator
11.4. StructLayout
12. Strings (Solutions) 12.1. PlusString 12.2. PlusChar 12.3. StringPlusNull 12.4. CaseInComparison 12.5. CorruptedNumber 12.6. CurrentCulture 12.7. CompareToVsEquals 12.8. CorruptedString 12.9. ExplicitlyInternment 12.10. NoStringInterning 12.11. InternmentAndMetadata 12.12. Secure 12.13. StableSorting 12.14. TextElementEnumerator
12.1. PlusString
12.2. PlusChar
12.3. StringPlusNull
12.4. CaseInComparison
12.5. CorruptedNumber
12.6. CurrentCulture
12.7. CompareToVsEquals
12.8. CorruptedString
12.9. ExplicitlyInternment
12.10. NoStringInterning
12.11. InternmentAndMetadata
12.12. Secure
12.13. StableSorting
12.14. TextElementEnumerator
13. Multithreading (Solutions) 13.1. ThreadStaticVariable 13.2. LockSlimInFinalizer
13.1. ThreadStaticVariable
13.2. LockSlimInFinalizer
Published using GitBook
This book is a collection of problems on the knowledge of the .NET platform and the C# programming language. To avoid misunderstandings, just want to say that the book is not :
This book is not a universal way to check your knowledge platform .NET. If you are easily solved all problems, it does not mean that you is a wonderful .NET-programmer. And if you met a lot of new things for yourself, then it does not mean that you don't know .NET.
This book is not a compilation of new, previously unseen problems. Many examples can be found in the literature, in questions on StackOverflow , in programmer's blogs. Just because they have become classics.
This book is not focused on those who already feel Senior .NET Developer and want to learn a lot.
So what is this book? ProblemBook.NET is an attempt to gather in one place a variety of interesting practical problems on the knowledge platform. Problems are divided into chapters, so you can not read everything, but only questions of those areas that are of interest to you. In this book you will not find a deep philosophical questions such as "What is a class?" or "Why is polymorphism needed?". Most of the problems is a piece of C#-code for which you should to determine the result. Each question is provided with a solution (sometimes with a description of why .NET behaves this way).
It is recommended to treat the problem is not as a way to test your knowledge as well as the starting point for the discussion of various aspects of the platform. If you find something new for yourself, it's a great cause to learn .NET a little more detail. Try to play around with the code: modify it and learn how changes affect the result. Read the relevant literature. Think about how the new knowledge can be useful to you in your work.
ProblemBook.NET distributed electronically, the development is on GitHub. It should also be noted that at present the problem book is far from the final version. The book will be updated with new problems and old will be refined and improved.
Today, there are two popular platform implementation .NET: The original Microsoft .NET Framework (hereinafter - MS.NET) and Mono. It is known that the behavior of some code fragments may change when you change the implementation. Similarly, the behavior might depends on the CLR or processor architecture. If the result of the fragment of the code depends on the environment, it is likely that the answers will be given an explanation. However, it is not guaranteed . If one of the examples you have received an answer that is different from this in the book, please contact the author, that he corrected this mistake.
Examples of code in all tasks can be run from LINQPad (in C# Statements or C# Program, depending on the availability of the method Main ), but you should import the following namespace (Query -> Query Properties -> Additional Namespace Imports):
The author sincerely thanks the Chief Editor Ivan Pashchenko for useful discussions during the writing of this book.
The author evinces appreciation to Ekaterina Demidova for the kindly providing illustrations.