Browsing 7239 questions and answers with Jon Skeet
Yes, that's thread-safe - although it's not the normal singleton pattern, as there are no instances of your class itself. It's more of a "single-value factory pattern". The class will be initialized exactly once (assuming nothing calls the... more 11/21/2014 7:05:01 AM
You've got your condition the wrong way round - CheckAccess() will return true when it's okay to modify the object in the current thread. Currently, you're saying, "If I'm already in the UI thread, call the method again in the UI thread"... more 11/20/2014 7:37:33 PM
However, the output shows that allCells[0,0] element was also changed. This means that any operation I do to the cloned array, is executed to the main array. Unless Cell is a struct, your setRegion method (which sounds like it should... more 11/20/2014 7:21:49 PM
Does every concrete sub-class have to have that same 1-param constructor Well, strictly speaking they don't have to have that constructor - but they'll need to have a constructor, in order to pass a value to the AbstractClass... more 11/20/2014 4:40:15 PM
I think you're looking for Buffer.BlockCopy. Buffer.BlockCopy(record, 0, target, 0, record.Length); I believe that will preserve the endianness of the architecture you're on - so it may be inappropriate in some environments. You might... more 11/20/2014 3:58:53 PM
You're currently writing output on each iteration of the inner loop... which means you're getting much more output than you want. You want to print out the result once per iteration of the outer loop, which means bringing count into the... more 11/20/2014 7:49:33 AM
The problem is that you're only looking at one param element - always the first one, because that's what the Element does. You want to match if any of the parameters is a "Store" element with a value of 1, so you want to use the Any... more 11/19/2014 8:23:33 PM
Firstly, I'd suggest avoiding using public fields - use properties if you want to make state public. (You're asking for a property in your reflection call, but your derived class declares a field...) At that point, you can make FullName... more 11/19/2014 5:34:03 PM
Your final method would fail because it's trying to declare a type parameter called string. I suggest you add another overload without the constraint on T, but with a default value: public T GetField<T>(SqlDataReader dr, string... more 11/19/2014 5:14:21 PM
Yup, you're just looking for the || (conditional-OR) operator: if (kTonerIsLow || cTonerIsLow || ...) { SendEmail(); } Note that the operator is short-circuiting - so if kTonerIsLow is true, it won't evaluate cTonerIsLow, etc. If... more 11/19/2014 2:55:13 PM