You can see what I’m trying (but failing) to do with the following code: protected T GetObject() { return new T(); } Any help would be greatly appreciated. EDIT:...
The class CancellationTokenSource is disposable. A quick look in Reflector proves usage of KernelEvent, a (very likely) unmanaged resource. Since CancellationTokenSource has no finalizer, if we do not dispose...
I wish to say: public void Problem(Guid optional = Guid.Empty) { } But the compiler complains that Guid.Empty is not a compile time constant. As I don’t wish to...
I am writing an HTTP server in C#. When I try to execute the function HttpListener.Start() I get an HttpListenerException saying “Access Denied”. When I run the app in...
Does C# 4.0 allow optional out or ref arguments? 11 Answers 11
C# 4.0 introduced a new type called ‘dynamic’. It all sounds good, but what would a programmer use it for? Is there a situation where it can save the...
What is the difference between the below code snippets? Won’t both be using threadpool threads? For instance if I want to call a function for each item in a...
Is there a way to use a Tuple class, but supply the names of the items in it? For example: public Tuple<int, int, int int> GetOrderRelatedIds() That returns the...
I would like to dynamically add properties to a ExpandoObject at runtime. So for example to add a string property call NewProp I would like to write something like...
I have following JSON string which is received from an external party. { "team":[ { "v1":"", "attributes":{ "eighty_min_score":"", "home_or_away":"home", "score":"22", "team_id":"500" } }, { "v1":"", "attributes":{ "eighty_min_score":"", "home_or_away":"away", "score":"30",...