Browsing 7239 questions and answers with Jon Skeet
No, in general (i.e. without custom rendering yourself) a label only has a single foreground colour. Assuming this is Windows Forms, it sounds like you might want a RichTextBox instead - that allows multiple colours, fonts etc within a... more 10/22/2013 6:08:45 AM
You could write a custom conversion operator: public struct Test { private readonly byte pop; private readonly byte svp; private readonly byte uhdp; private readonly byte mhdp; // TODO: Properties to return the... more 10/21/2013 4:45:15 PM
It sounds like you're looking for TaskCompletionSource<T>. You'd wrap your library by creating a TaskCompletionSource, creating an instance of MyNativeLibrary and registering a callback which set the result of the task completion... more 10/21/2013 1:46:50 PM
No, an interface in C# can't declare fields at all. You can't declare a static interface at all in C#, nor can you declare static members within an interface. As per section 11.2 of the C# specification: An interface declaration may... more 10/21/2013 1:41:09 PM
Your accept method declares new local variables for p, n and r - it doesn't assign values to the instance variables, which will still have a value of 0. Rather than declaring local variables, you should just assign values to the instance... more 10/21/2013 1:34:01 PM
No. The closest you could come is to add a finalizer - possibly conditionally so that it's only included for debug builds - which checks whether or not you've been disposed and logs the problem otherwise. (You'd probably want to keep the... more 10/21/2013 1:01:46 PM
Why cannot I type foreach(var vari in variables)? Well you can - but then vari is implicitly of type object. You happen to know that each entry within the iterator is a DictionaryEntry, but the compiler doesn't. As far as it's aware,... more 10/21/2013 8:44:40 AM
An enum can contain values which differ only in case - you just can't declare them in VB. This is perfectly valid C#: public enum Foo { A, a; } Additionally, even if the enum couldn't contain values differing only in case, that... more 10/21/2013 8:39:49 AM
There are two problems here: You've got a void async method, which is almost always a bad idea unless it's meant to be an event handler. You should generally make an async method return Task where you'd normally write a void synchronous... more 10/21/2013 8:36:59 AM
It there a reason for not allowing a reference to a static class within enum initializer? It's a static field that you're not allowed access to, and there's a very good reason: the field will still have its initial value, because the... more 10/21/2013 6:06:22 AM