Using cheaper variable types in C#

I would like to know if I use “cheaper” variable type (byte for example) is beneficially affects the performance? In RPGs for experience level for example, no one need above 2 million limit (as integer have this). Byte is excellent in this case, but using different types I have to convert it in many situations, so I asking for it.

I am working on mmo side project time to time on holidays. I know exactly what you are worrying about. At the end of the day, for client - do not prematurely optimize these things. It’s always easier step down to a byte rather than going up to int. And i have invested hundreds of hours prematurely optimizing this type of code, but it was all wasted when simple core machanics changed and that code was no longer in need, I cri evrytiem.

It’s funny, especially in unity, when a lot of programmers ask about such optimizations, but at the same time throw out thousands of useless byte allocations per frame in simple update loops, but try to save 2-10 bytes in cached class.

If you’re talking about sending packets of data across a network, synchronising player data across many clients 60 times a second, then this kind of micro-optimisation becomes important. In 95% of cases, however, it is unnecessary and has an unnoticeable impact on performance on any modern device.