Trying to understand this abstract code (and use it elsewhere) - C#