Last active
August 27, 2015 11:17
-
-
Save sonicflare/a37f945e5b418fced921 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace ConsoleApplication7 | |
{ | |
internal class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
Static<int>.Add(1); | |
Console.WriteLine(Static<int>.Count); //1 | |
Static<string>.Add("1"); | |
Console.WriteLine(Static<string>.Count); //1 | |
Static<int>.Add(2); | |
Console.WriteLine(Static<int>.Count); //2 | |
Static<string>.Add("3"); | |
Console.WriteLine(Static<string>.Count); //2 | |
Static<double>.Add(3.4f); | |
Console.WriteLine(Static<double>.Count); //1 | |
Console.ReadKey(); | |
} | |
public static class Static<T> | |
{ | |
public static readonly List<T> _items = new List<T>(); | |
public static int Count | |
{ | |
get { return _items.Count; } | |
} | |
public static void Add(T item) | |
{ | |
_items.Add(item); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment