Skip to content

Instantly share code, notes, and snippets.

@gempir
Last active September 14, 2016 12:06
Show Gist options
  • Save gempir/f891125eccf1e73e63043a09127d7a4b to your computer and use it in GitHub Desktop.
Save gempir/f891125eccf1e73e63043a09127d7a4b to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
namespace a
{
class Program
{
public static void Main(string[] args)
{
GenericCache cache = new GenericCache();
cache.save("name", "Daniel");
Console.WriteLine(cache.get("name"));
Console.ReadKey();
}
}
class GenericCache
{
Dictionary<T,T> cache = new Dictionary<T,T>();
public void save<T, T>(T key, T value)
{
cache.Add(key, value);
}
public T get<T>(T key)
{
return cache[key];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment