Well,
the question is kinda simple.
I have a object defined as:
public class FullListObject : System.Collections.ArrayList, IPagedCollection
And when i try to:
IPagedCollection pagedCollection = (IPagedCollection)value;
It don’t work… value is a FullListObject… this is my new code trying to get around a issue with the “is” operator. When the system tests (value is IPagedCollection) it never gets true for FullListObject.
How to cast the object to another object with a interface type?
EDIT:
Just for the record: the bugger code
if (value is IPagedCollection)
{
IPagedCollection pagedCollection = value as IPagedCollection;
The if was never hitting true, and forcing the conversion wasn’t working too. So the issue was the double definition of classes. Now i defined the FullObjectList in a “Commom” project for classes used by the whole system. Problem gone!
You’re doing it right. Try this (it will fail also but show the problem):
The compiler should accept this just fine. If not, you have multiple definitions of either
IPagedCollectionand/orFullListObjectwhich conflict each other. If that fails at runtime, your value is not aFullListObject.