This code will work if you had an implicit conversion from string to Employee . Basically, a string literal is of type string - that is, its value is a reference to the string (and interned in it). You can assign a value of one type to a variable of another type if there is a conversion between the two types - either user-defined or built-in. In this case, there is no conversion from string to Employee , therefore, an error.
Unlike some other answers, the types do not have to be the same - for example, this is normal:
object x = "string literal";
This is great because there is an implicit conversion of links from string to object . You can also write:
XNamespace ns = "some namespace";
because there is an implicit conversion from string to XNamespace .
To answer the second question: see if a type in .NET is a value type or a reference type ... struct and enum types are value types; everything else (class, delegate, interface, array) is a reference type. This excludes pointer types that are slightly different :)
source share