I\'ve seen both done in some code I\'m maintaining, but don\'t know the difference. Is there one?
let me add that myCustomer is an instance of Customer
typeof(foo) is converted into a constant during compiletime. foo.GetType() happens at runtime.
typeof(foo) also converts directly into a constant of its type (ie foo), so doing this would fail:
public class foo
{
}
public class bar : foo
{
}
bar myBar = new bar();
// Would fail, even though bar is a child of foo.
if (myBar.getType == typeof(foo))
// However this Would work
if (myBar is foo)