I need to cast a featureclass to IPolyline. In this piece of code below
IFeatureClass fcR = gHelp.GetFeatureClass(pWS2, fNameR);
ESRI.ArcGIS.Geometry.IPolyline refLine = fcR as ESRI.ArcGIS.Geometry.IPolyline;
the IPolyline refLine is null. What's wrong in this piece of code? Thanks if you can help.
I found my mistake in my post. The correct way is to cast a line feature of a featureclass as an IPolyline:
ESRI.ArcGIS.Geometry.IPolyline pLine = (ESRI.ArcGIS.Geometry.IPolyline)feature.ShapeCopy;
Thanks for your review.
Hi Shuping,
You are correct in your findings. You cannot cast a FeatureClass to IPolyline because a feature class is a collection of polyline. As you discovered, you'd first need to get a feature (IFeature) from the polyline feature class and then you could cast its shape to IPolyline.