views:

124

answers:

1

Possible Duplicates:
typedef in C#?
STL like containter typedef shortcut?

I was wondering if there was an equivalent to Type aliasing from Functional Languages that I can use in C#

For example in a nice functional language like Haskell I can say something like the following to alias an existing type to a custom Type Name

type MyCustomTypeName = String

I'd like to do this as I have an API that I'm building where some of the Objects I'm using have multiple possible names in the sense they could be referred to by several terms which are interchangeable and equivalent. Presumably I could do this with inheritance but that seems somewhat clunky and then potentially breaks if people start extending the non-canonical class ie.

public class CanonicalClass {
  //Full Implementation
}

public class AlternateName : CanonicalClass {
 //Empty except I'll need to redefine all the constructors
 //Could declare it sealed but doesn't get rid of the need to redefine constructors
}

And before anyone mentions interfaces all the Classes in question are all implementing interfaces already and there are multiple differing implementations of these interfaces.

A: 

Depending on what you're actually trying to do (give a somewhat more complete example), you may indeed need interfaces (used properly) and/or generics.

Matthew Flaschen