is the default value for generics.

the example you quoted says

the compiler will automatically help us determine the type of T based on the passed parameters

while in JQueryStatic , the passed parameter has nothing to do with TElement . In other words, it cannot be inferred automatically. At this point, you can specify a default value.

< hr >

the example quoted by the subject says "incoming parameter", so I followed this loose expression, but it seemed to lead to confusion.

the "incoming parameter" here refers to what is in parentheses, that is, the formal parameter of the function. If TElement does not appear in parentheses, it is impossible to automatically infer generics based on the arguments at the time of the call. As for the constraints of generics, they can appear at the same time as the default value or at different times, and there is no inevitable relationship between the two.

strictly speaking, the word "incoming" cannot be matched with the word "generic parameter". Generics are used at definition time, and the runtime is removed.

add an example:

  

Thank you, boss, for solving the confusion

.
Menu