C#

C# stuff.

Moved

This blog is now over at http://jonathan.dickinsons.
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Wrapping on Specific Characters

Wrap on specfic characters during a S.D.Graphics.DrawString()

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Unbox Enum as Integral Value

I needed a way to get the integral value of an System.Enum that is boxed. The solution wasn't immediately obvious after my experimentation mainly because: My enum was derived from byte (and I was trying to cast it to an int). My .Net jitsu wasn't up to scratch. Lucky thanks to a friendly guy called Guffa I managed to create generic solution. As it turns out you can unbox an enum value to its base type. As such the following can be unboxed to an uint. struct FoolishStruct : uint { Gluttony, Pride,...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Ternary If Statement in C#

Sometimes you just need a ternary statement, i.e. you don't want to return a value from the condition ? true : false construct. Here is an extension method to help you out (the usage example isn't the best). class Program { static void Main(string[] args) { List<string> test = new List<string>(); ArrayList source = new ArrayList(); source.Add(1); source.Add("hello"); source.Each<object>(x => (x is String).IfElse ( () => test.Add((string)x), () => test.Add(x.ToString())...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Ruby-like each statement in C#

Funny this isn't in the provided Enumerable extension methods. In any case, here it is: internal static void Each<T>(this IEnumerable<T> @this, Action<T> action) { foreach(T t in @this) action(t); } internal static void Each<T>(this IEnumerable @this, Action<T> action) { foreach (object t in @this) if (t is T) { action((T)t); } } An example: objects.Each(x => DoSomethingFunky(x, "some parameter"));...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Forcibly Closing a Start Tag with XmlTextWriter

How to get a XmlTextWriter to make one of these bad boys: ">"

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

ROAM landscapes with XNA

My XNA ROAM implementation.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

TFS Build Server 2005 with 2008 Solutions

Better shim for building 2008 projects on TFS Build Server 2005.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Long-Running Webservice Without Polling

Async Webservices: The proper way.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Serialization using XElements

One thing that I found missing was the ability to serialize objects directly into XElements with the new XML LinQ in .Net. I made a small solution to really bring power into the framework.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Full C# Archive

«February»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910