Share reports from favorites
Release:, updated:1. In a switch statement, if no case expression matches the switch value, the control is passed to the statement following the optional default label. If no default tag exists, the control is passed outside the switch. 2. How to assign the default value to parameterized type T when the following conditions are unknown in the generic class and generic method: whether T is a reference type or a value type, if t is of the value type, whether it is a value or a structure. Public class genericclass <t>
{
Public t dosomething (ARG)
{
T temp = default (t );
If (Arg! = NULL)
{
Temp = Arg. favs;
}
Return temp;
}
} Given a variable t of the parameterized type T, the Statement t = NULL is valid only when T is of the reference type. Only when T is of the numerical type rather than the structure, statement t = 0 can be used normally. The solution is to use the default keyword, which returns NULL for the reference type and zero for the value type. For the structure, this keyword returns each structure member whose Initialization is zero or empty, depending on whether the structure is a value type or a reference type