In C# when debugging threads for example, you can see each thread's ID.
This will be the Ids of the managed threads. ManagedThreadId
is a member of Thread
so you can get the Id from any Thread object. This will get you the current ManagedThreadID:
Thread.CurrentThread.ManagedThreadId
To get an OS thread by its OS thread ID (not ManagedThreadID), you can try a bit of linq.
int unmanagedId = 2345;
ProcessThread myThread = (from ProcessThread entry in Process.GetCurrentProcess().Threads
where entry.Id == unmanagedId
select entry).First();
It seems there is no way to enumerate the managed threads and no relation between ProcessThread and Thread, so getting a managed thread by its Id is a tough one.
For more details on Managed vs Unmanaged threading, see this MSDN article.