How do I determine whether the types of two objects are compatible?

前端 未结 4 1188
孤城傲影
孤城傲影 2021-01-15 08:12

I have a generic function that I want to know how to write.

List something;

public int countItems(List Items)
{
    // He         


        
4条回答
  •  终归单人心
    2021-01-15 08:50

    if (something.GetType() == items.GetType()) ...
    

    This will compare the types of the actual objects.

提交回复
热议问题