I have two IHeaderRow interfaces, and IDetailRow
Then I have an object that implements as RawRow: IHeaderRow, IDetailRow
Then I need to pass it to HeaderRow , which implements IHeaderRow .
But when I try, it ends with zero or gives an exception.
I can use ObjectRawRow for the IHeaderRow or IDetailRow interface
var ObjectIHeaderRow = ObjectRawRow as IHeaderRow; var ObjectIDetailRow = ObjectRawRow as IDetailRow;
But I can not distinguish ObjectRawRow from HeaderRow or ObjectIHeaderRow to HeaderRow .
It throws an error. Cannot convert source type "IA" to target type "A"
I need to include it in the actual HeaderRow class.
Thoughts?
EDIT:
Despite the fact that setting the explicit throw took care of the problem, I thought that I would give an answer to people who are wondering WHY I did what it was.
In short, I process the file sequentially. Line by line. I read the line in RawRow, and until I look at a few values, I really don't know what type of line it will be. Then I wanted to classify it as appropriate.
casting c # interface
Caffgeck
source share