object A = new object();
object B = new object();
lock (B) Console.WriteLine("locked A, then B");
lock (A) Console.WriteLine("locked B, then A");
When you comment Thread.Sleep line you can easily understand whats happening.
A deadlock will only occur if you have more than one lock. You need a situation where both threads hold a resource that the other needs (which means there has to be a least two resources, and the two threads have to attempt to acquire them in a different order)
Everything in C# language is an Object, there are no primitive types in the classic sense.
That means string is not a truly primitive types, it is an object instance of a Class.
System.String and string are compiled to System.String in Intermediate Language (IL), so there is no difference in the performance, and it's purely a personal choice.
string is an alias for System.String. They compile to the same code, so at execution time there is no difference . This is just one of the aliases in C#. The complete list of alias is: