[Mono-list] Trouble accessing interface methods via as operator

Joe Scaduto scooch@noggle.biz
Tue, 13 Apr 2004 03:39:54 -0400


I am trying to use the 'as' operator to access interface methods. I am
using reflection to create an instance of the class which implements the
interface. I am able to obtain the object but the 'as' operator always
returns null for me even though the class does implement the interface. 
I am not sure what is going.  Any help would be greatly appreciated.

code snippet:

System.Object obj = Activator.CreateInstance(type);
IServices current = obj as IServices;

if (current == null)
	Console.WriteLine("obj does not implement IServices");