What does the keyword “where” in a class declaration do?

前端 未结 7 1151
天涯浪人
天涯浪人 2020-12-17 17:24

I\'m looking at the source code for the MvcContrib Grid and see the class declared as:

public class Grid : IGrid where T : class

7条回答
  •  萌比男神i
    2020-12-17 18:09

    It is a constraint on the type argument which says that T can either be a class or an interface but not an enum or a struct. So T must be a reference type and not a value type.

    Best Regards,
    Oliver Hanappi

提交回复
热议问题