Почему, если я включаю INT16 [] в C#, он будет соответствовать UINT16 [] , даже если INT16 [] присутствует позже в операторе Switch?namespace SwitchError;
internal class Program
{
static void Main(string[] args)
{
Int16[] arr = new Int16[50];
Console.WriteLine($"Arr is {((arr is UInt16[]) ? " " : "not ")}UInt16[]");
Console.WriteLine($"Arr is {((arr is Int16[]) ? " " : "not ")}Int16[]");
PrintInfo(arr);
}
static void PrintInfo(T[] array)
{
string message = array switch
{
double[] b => "Double",
UInt16[] b => "Unsigned Int16",
Int16[] b => "Signed Int16",
_ => "Unknown type"
};
Console.WriteLine("Switch statement says it is an: " + message);
}
}
< /code>
output: < /p>
Arr is not UInt16[]
Arr is Int16[]
Switch statement says it is an: Unsigned Int16
Подробнее здесь: https://stackoverflow.com/questions/795 ... int16-in-c
Почему сопоставление шаблонов совпадает Int16 [] uint16 [] в C#? ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Подпись HMAC не совпадает и не принимается API AROFLO в коде PHP, но совпадает через Node.js.
Anonymous » » в форуме Php - 0 Ответы
- 48 Просмотры
-
Последнее сообщение Anonymous
-