Brent Waggoner, Web Developer

Class2Dictionary: Reflection for a Key/Value World


Class2Dictionary is a simple utility extension method to convert a class into a dictionary. It was useful and so small and self-contained that I thought I’d share it with the world. It uses reflection to populate a Dictionary<string, string> with the property names and values in a class.


C2D is an extension method and will work on any object that inherits the IC2D interface.

public class SampleClass : IC2D
   public int Id { get; set; }
   public string FirstName { get; set; }
   public string LastName { get; set; }
   public string Company { get; set; }

It can be used like this:

var sampleClass = new SampleClass();
var dictionary = sampleClass.ConvertC2D();

It returns a dictionary containing the property names as the keys, and the property values as the values.

I built it for use in sending POST requests but thought someone else might find it useful.

It can be viewed as well as pulled on GitHub.

I Build Things

Need a solution for your website or business? Contact Me!

Recent Posts

What I Do

I love to build things. I love making the web work.

Tools I Use:

  • C#
  • .NET MVC
  • Javascript / jQuery
  • Angular
  • PHP
  • SQL / MySQL

But what really matters is solving your problems. I can do that too.

What I've Done

  • JointCharge joint supplement is a great product that needed a great site. With a responsive layout and a custom eCommerce solution, they're helping more pets than ever.

  • IlluminedNation helps match the right person to the right job. We automated their process so companies could more easily benefit from their experise.

  • Diamond Deluxe is one of three sites that needed a responsive makeover without a whole new design. Using Bootstrap and some custom menus, we moved it into the mobile age.

What Can I Do For You?

Need a web site? Fill out the form below and I'll contact you to work out the details. Or email me directly at

Thanks for your request!