Is it possible to check if the object's type is a part of a particular namespace from C# code? If yes, how?
I need to check if e.OriginElement as FrameworkElement
is one of the MS.Internal
controls.
To determine whether an object is a specific type, you can use your language's type comparison keyword or construct.
GetType Method is used to find the type of the current instance. This method returns the instances of the Type class that are used for consideration.
A namespace is a logical design-time naming convenience, used mainly to define scope in an application and organize classes and other types in a single hierarchical structure. From the viewpoint of the runtime, there are no namespaces.
You can inspect the Type.Namespace property.
e.OriginElement.GetType().Namespace
e.OriginElement.GetType().Namespace
should give you the information you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With