Domanda

Ho bisogno di eseguire un bit a bit spostamento a sinistra su un intero a 16 bit (ushort / UInt16), ma gli operatori bit per bit in C # sembra applicarsi a int (32 bit) solo. Come posso utilizzare << su un ushort, o almeno raggiungere lo stesso risultato con un semplice workaround?

È stato utile?

Soluzione

Fusioni retro valore risultante in USHORT dopo lo spostamento:

ushort value = 1;
ushort shifted = (ushort)(value << 2);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top