Change function behavior depending on class' generic type. - C#