Cannot implicitly convert type 'T' to 'Int'

后端 未结 6 1815
轻奢々
轻奢々 2020-12-16 14:38

When trying to call this function in my code i get the error in the title. Also Operator \'+=\' cannot be applied to the operands of type \'int\' and \'T\'

p         


        
6条回答
  •  情深已故
    2020-12-16 15:26

    Or another way (object cast is necessary not typo)

    t += (int)(object)value;

    Or use dynamic, by using dynamic you can do more, such as implicit casts

    Or use Int32 - Int32 and int are both struct internally. No performance loss

提交回复
热议问题