I am just wondering what the process is for checking the object type of something.
Basically I have an array of parent objects and I want to check if one of those objects is of a particular child type.
more specifically, I want to check if an array of GameScreen objects contains a GameScreen object of type GameplayScreen.
GameScreen[] screens = mScreenManager.GetScreens();
// loop through array and check if the object equals gameplayscreen
}
You can check the type using
is
operator like:Or if you just need
GamePlayScreen
type objects from your array you can use :See: Enumerable.OfType. It uses
System.Linq
Use the
is
keyword when you want to check a type.You can do the same for your GamePlayScreen.