How to specify a short int literal without casting?

前端 未结 6 1527
温柔的废话
温柔的废话 2020-12-15 02:20

Is there a way to specify that my variable is a short int? I am looking for something similar to M suffix for decimals. For decimals, I do not have to say

va         


        
6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 02:51

    You can use the following:

    var value = (short)123;
    

    Of course it doesn't really make sense since the whole point of var is not to write the type.

提交回复
热议问题