固定大小的字节数组 [英] Fixed Size Byte Array

查看:88
本文介绍了固定大小的字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public : array<Byte>^ Foo(array<Byte>^ data)

获取动态大小的管理数组

gets dynamic size managed array

但是如何获取固定大小的管理字节数组?

but how can I get fixed size managed byte array?

我想强制C#用户发送我8字节数组;并返回8个字节

I wanna force C# user to send me 8 byte array; and get 8 bytes back

style:

public : Byte[8] Foo(Byte[8] data)

EDIT:

可以任何1解释为什么它的安全上下文中的不可能。

can any1 explain why its impossbile in safe context?

推荐答案

不允许你这样做。你只需要验证数组的长度,如果长度不是8就可能抛出异常。

C# does not allow you to do that. You'll simply have to validate the array's length and maybe throw an exception if the length is not 8.

此外,函数的类型不能是 Byte [8] ;您必须将其更改为 Byte []

Also, the type of your function can't be Byte[8]; you'll have to change that to Byte[].

这篇关于固定大小的字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆