Friday, December 8, 2017

Make a simple generic that basically just wraps another type in C#.

namespace Whatever
{
   public class Wrapper<T>
   {
      public T Data { get; set; }
      public string Metadata { get; set; }
   }
}

 
 

Use it like this:

Wrapper<int> wrapper = new Wrapper<int>();
wrapper.Data = 13;
wrapper.Metadata = "It's lucky!";

No comments:

Post a Comment