If the layer is a feature layer, you can get IPolyline from each IFeature by IFeature.Shape Property.
IPolyline polyline = feature.Shape as IPolyline;
IPoint fromPoint = polyline.FromPoint;
IPoint toPoint = polyline.ToPoint;
Now create a point feature class and add these points as feature to that feature class.
EDIT
I am guessing you are working with all features of your feature class. If that is not right, just change the search method as you need:
List<IFeature> GetAllFeatures(IFeatureClass ArcFeatureClass)
{
var featureCursor = ArcFeatureClass.Search(null, false);
var features = new List<IFeature>();
Geodatabase.IFeature feature;
while ((feature = featureCursor.NextFeature()) != null)
features.Add(new Feature(feature));
return features;
}
List<IPoint> GetEndPoints(List<IFeature> features)
{
var points = new List<IPoint>();
foreach(var feature in features)
{
var polyline = feature.Shape as IPolyline;
points.Add(polyline.FromPoint);
points.Add(polyline.ToPoint);
}
return points;
}
Now create a point feature class. Suppose, name of that feature class is 'pointFeatureClass'. If you need help to create feature class, you can go through this.
void AddFeatures(List<IPoint> points, IFeatureClass pointFeatureClass)
{
if (pointFeatureClass == null)
return;
foreach (var point in points)
{
IFeature feature = pointFeatureClass.CreateFeature();
feature.Shape = point;
feature.Store();
}
}
This code will put a point on each end of a polyline. For your figure, it will create 8 points. If you want to customize it, you can put your own logic.