listbox - Get Type from a list element c# -


I have a C # list box, which is full of elements of class "human", every element belongs to a class Which was derived from human like "Old", "Young" I want to know whether the selected element is old in the list box

thanks in advance

You can use it:

  var query = myListBox.Items.Cast & lt; Human & gt; (). Select (H = & gt; new {ISLld = H is old, isang = h is young, human = H});   

Edit : "I want to know whether the selected element is in the list box old"

You do not need LINQ query again:

  human human = (human) myListBox.SelectedItem; Bool isOld = Human is old;    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -