如何获得vbfixedstring(5)中定义的结构变量的大小? [英] How can I get a size of the structure variable defined in vbfixedstring(5)?

查看:265
本文介绍了如何获得vbfixedstring(5)中定义的结构变量的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好



我正在处理从vb6到vb.net的转换项目。



旧项目包含声明字符串大小的VBFixedString,它们从结构中检索大小。但是在将项目转换为VB.Net之后,代码已经像下面显示的代码一样进行迁移。



私有结构StructureName

Hi

I am working on converted project from vb6 to vb.net.

The old project contains the VBFixedString of declaring a size of the string and they retrieving the size from the structure.But After converted project to VB.Net the code has been migrated like the code shown below.

Private Structure StructureName

<VBFixedString(2), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=2)> Public xxx() As Char



结束结构



但我无法检索大小变量



我尝试过:




End Structure

But I can't able to retrieve the size of the variable

What I have tried:

I tried marshal,but it gives the total size of the structure alone.

Marshal.SizeOf(X)

Can someone give me a solution to retrieve the size of the particular variable inside the structure which is using VBFixedString or else give me some suggestions to declare the variable by defining size inside the structure to retrieve the size?

Thanks in Advance.

推荐答案

看看这些;



[ ^ ]



sizeof vs Marshal.SizeOf [ ^ ]
Look at these;

Marshal variable length array of structs from C to VB.NET[^]

sizeof vs Marshal.SizeOf[^]


这篇关于如何获得vbfixedstring(5)中定义的结构变量的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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