随笔分类 - C#
摘要:Why are C# 4 optional parameters defined on interface not enforced on implementing class? UPDATE: This question was the subject of my blog on May 12th
阅读全文
摘要:Why use a public method in an internal class? UPDATE: This question was the subject of my blog in September 2014. Thanks for the great question! There
阅读全文
摘要:cannot implicitly convert type 'bool?' to 'bool'. An explicit conversion exists (are you missing a cast?) As the others stated bool? is not equal to b
阅读全文
摘要:System.IO.FileLoadException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one o
阅读全文
摘要:Does Dispose still get called when exception is thrown inside of a using statement? Yes, using wraps your code in a try/finally block where the finall
阅读全文
摘要:Why use a public method in an internal class? UPDATE: This question was the subject of my blog in September 2014. Thanks for the great question! There
阅读全文
摘要:Why can two different enum enumeration-constants have the same integer value? C enums are "really" integers -- not just because they happen to be impl
阅读全文
摘要:http://www.codewars.com/kata/56676e8fabd2d1ff3000000c/train/csharp Can you find the needle in the haystack? Write a function findNeedle() that takes a
阅读全文
摘要:打开dll的源码,然后attach到那个加载了反射dll的进程上。 就可以调试dll的代码
阅读全文
摘要:Why you need to understand garbage collection I’ve been interviewing lots of C# developers recently, and one of my stock questions is “how does the .N
阅读全文
摘要:这个错误,在使用List<T>的First函数遇到。 Sequence contains no elements? From "Fixing LINQ Error: Sequence contains no elements": When you get the LINQ error "Sequen
阅读全文
摘要:Check if List<Int32> values are consecutive One-liner, only iterates until the first non-consecutive element: bool isConsecutive = !myIntList.Select((
阅读全文
摘要:Why would I want to use an ExpressionVisitor? There was a issue where on the database we had fields which contained 0 or 1 (numeric), and we wanted to
阅读全文
摘要:Interpreting Expressions
阅读全文
摘要:Traverse an expression tree and extract parameters I think as you've said that using ExpressionVisitor works out to be a good approach. You don't need
阅读全文
摘要:Get Argument Values From Linq Expression If you even find yourself unpacking an expression in C#, you might find this useful. I found myself in need o
阅读全文
摘要:Like anonymous methods, iterators in C# are very complex syntactic sugar. You could do it all yourself (after all, you did have to do it all yourself
阅读全文
摘要:What is the use of c# “Yield” keyword ? “Yield keyword helps us to do custom stateful iteration over .NET collections.” There are two scenarios where
阅读全文
摘要:What is the yield keyword used for in C#? 回答1 The yield keyword actually does quite a lot here. The function returns an object that implements the IEn
阅读全文
摘要:https://en.wikipedia.org/wiki/Coroutine Coroutines are computer program components that generalize subroutines for non-preemptive multitasking, by all
阅读全文