Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

How to Cast a EntityObject to an specific Entity like LwPolylineVertex? #269

Answered by haplokuon
Jan21021 asked this question in Q&A
Discussion options

You must be logged in to vote

Casting an EntityObject to the specific type of entity is done like any other casting, there is nothing special about it as long as you are casting your object to the correct class that inherits from it. You cannot do what the question in your title suggest "How to Cast a EntityObject to an specific Entity like LwPolylineVertex?", the LwPolylineVertex class does not inherit from EntityObject. You can find more specific instructions on how casting is done in the documentation of the C# language.

EntityObject entity;

LwPolyline p1 = (LwPolyline) entity; // this is not safe since multiple entity classes inherit from EntityObject

// perform a safe cast, there are several methods the syntax …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Jan21021
Comment options

Answer selected by haplokuon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants