我需要在我的项目中使用 AES 算法,所以我想为所有要加密的数据设置一个常量 key 。如何在 C# 中创建一个可用作 key 的全局常量字节数组?
最佳答案
您可以创建的唯一 byte[]
常量如下:
const byte[] myBytes = null;
那是因为 byte[]
(或一般的每个数组)是一个引用类型,并且引用类型常量只能有 null
值分配给它(除了string
类型,可与字符串字面量一起使用)。
Constants can be numbers, Boolean values, strings, or a null reference.
关于c# - 如何在 C# 中创建字节数组常量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29135550/