ZForge.Win32.RemovableDriveDetector.DriveMaskToLetter C# (CSharp) Méthode

DriveMaskToLetter() private static méthode

Gets drive letter from a bit mask where bit 0 = A, bit 1 = B etc. There can actually be more than one drive in the mask but we just use the last one in this case.
private static DriveMaskToLetter ( int mask ) : char
mask int
Résultat char
        private static char DriveMaskToLetter(int mask)
        {
            char letter;
            string drives = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            // 1 = A
            // 2 = B
            // 4 = C...
            int cnt = 0;
            int pom = mask / 2;
            while (pom != 0)
            {
                // while there is any bit set in the mask
                // shift it to the righ...
                pom = pom / 2;
                cnt++;
            }

            if (cnt < drives.Length)
                letter = drives[cnt];
            else
                letter = '?';

            return letter;
        }