/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/fundamentals/runtime-libraries/snippets/System/Byte/Overview/csharp/bitwise1.cs
25 строк
686 B
Genevieve Warren
Add remarks for core types (#38970)
05 янв 2024, 22:14
Не верифицирован
05 янв 2024, 22:14
71d1377
Код
Авторство
О чём код?
// <Snippet1> using System; using System.Globalization; public class Example { public static void Main() { string[] values = { Convert.ToString(12, 16), Convert.ToString(123, 16), Convert.ToString(245, 16) }; byte mask = 0xFE; foreach (string value in values) { Byte byteValue = Byte.Parse(value, NumberStyles.AllowHexSpecifier); Console.WriteLine("{0} And {1} = {2}", byteValue, mask, byteValue & mask); } } } // The example displays the following output: // 12 And 254 = 12 // 123 And 254 = 122 // 245 And 254 = 244 // </Snippet1>