Category Archives: Recruitment

Type check and inheritance – and a nice ReSharper tip

Let’s suppose you have three classes in a simple hierarchy :

public class A

public class B : A

public class C : A

Now suppose you receive an instance of one of these classes (you don’t know the exact type to which this instance belongs). How can you determine programatically if the instance is of a type inheriting from A or it is of type A exactly?

Normally I would do the following :

var instance = ObtainInstanceFromSomeWhere(); // this method will not return null
var instanceIsExactlyOfTypeA = typeof(A) == instance.GetType();
var instanceIsOfTypeAOrAnInheritingType = typeof(A).IsAssignableFrom(instance.GetType());

All these work and are nice and dandy. However ReSharper showed me a nicer alternative to the last statement :

var instanceIsOfTypeAOrAnInheritingType = typeof(A).IsInstanceOfType(instance);

Now, pro’lly, many of you knew about this method but I didn’t! 🙂
Hopefully it will help someone..

How to deal with unwanted LinkedIn invites

How many of haven’t received unwanted LinkedIn invites from people that claim to know you, been colleagues and you haven’t even heard of?

Like… so :

or like so :

Don’t be fooled, they’re just trying to get their recruitment bonus. The right choice? The “REPORT SPAM” button up above. Press it. They deserve it. The correct way would have been a private message but it’s more useful for the recruiters to add a new contact since they may need to contact him/her again.