Question: I ran across the following class in a C# XNA graphics api and I am not sure what it does or that it needs to be so obscure. (T is constrained to be a struct in a parent class)

```
    static class Ident
    {
        static object sync = new object();
        static volatile int index = 0;
        static int Index
        {
            get
            {
                lock (sync)
                    return index++;
            }
        }
        class Type<T>
        {
            public static int id = Index;
        }
        public static int TypeIndex<T>()
        {
            return Type<T>.id;
        }
    }

```

The API makes only on call to this static class: `int index = Ident.TypeIndex<T>();`

Answer: 
It assigns an application-wide (static) and thread-safe(locking sync object + volatile index) unique identifier for each different type T.

example :

```
Console.WriteLine(Ident.TypeIndex<int>()); // 0
Console.WriteLine(Ident.TypeIndex<string>()); // 1
Console.WriteLine(Ident.TypeIndex<long>()); // 2
Console.WriteLine(Ident.TypeIndex<int>()); // 0

```

Volatile is being used to ensure that the current thread doesn't cache the index value and locking prevents more than one thread to access it.
It returns the number of times Ident.TypeIndex was called, probably to assign a unique number to each object.

Because of the way they are using generics, there should be a different sequence of numbers for every type T. So you could have a #1 circle, a #2 circle, and a #1 square.