Does C# have an equivalent to Scala's structural typing?
- by Tom Morris
In Scala, I can define structural types as follows:
type Pressable { def press(): Unit }
This means that I can define a function or method which takes as an argument something that is Pressable, like this:
def foo(i: Pressable) { // etc.
The object which I pass to this function must have defined for it a method called press() that matches the…