P
Peter Kirk
Hi
in C# is it possible to restrict the values that may be supplied to a
function, like this:
public IList GetList( int param )
where param can only take values 1 - 3, for example. Of course I can do it
in code, but I mean that the client of my function can see he can only
supply 1,2, or 3.
Can I use some sort of "enum" and specify the parameter as this "enum" type?
Also, is it possible to define special values in an interface? For example,
I want to define an interface for my class with the "GetList( int param )"
function - can I define the restricted type for param in this interface, so
that all implemtors can only use this type, and clients can see from the
interface what the possible values are?
Thanks,
Peter
in C# is it possible to restrict the values that may be supplied to a
function, like this:
public IList GetList( int param )
where param can only take values 1 - 3, for example. Of course I can do it
in code, but I mean that the client of my function can see he can only
supply 1,2, or 3.
Can I use some sort of "enum" and specify the parameter as this "enum" type?
Also, is it possible to define special values in an interface? For example,
I want to define an interface for my class with the "GetList( int param )"
function - can I define the restricted type for param in this interface, so
that all implemtors can only use this type, and clients can see from the
interface what the possible values are?
Thanks,
Peter