Do you want to do this at the client level?
If so use a static member field of
int
type. And increment it in a getter. Use locking to make it thread safe.
Quickly put together untested sample code:
static class AutoNumber
{
static object synclock = new object();
static int number = 0;
public static int Next
{
get
{
lock(synclock)
{
return ++number;
}
}
}
}
Alternate approach without the lock:
static class AutoNumber
{
static int number = 0;
public static int Next
{
get
{
return Interlocked.Increment(ref number);
}
}
}