超难问题(C#重写C结构)
各位高手们谁会啊
比如:
struct userInfo
{
char[50] naem,
char[8] sex,
char[18] identID
}
怎么转成C#啊
------解决方案--------------------struct userInfo
{
string naem;
string sex;
string identID;
}
直接用string就可以
------解决方案--------------------struct userInfo
{
public string naem;
public string sex;
public string identID;
}
------解决方案--------------------兄弟,这样试试:
public struct UserInfo
{
[ MarshalAs( UnmanagedType.ByValArray, SizeConst=50 )]
public byte[] name;
[ MarshalAs( UnmanagedType.ByValArray, SizeConst=8 )]
public byte[] sex;
[ MarshalAs( UnmanagedType.ByValArray, SizeConst=18 )]
public byte[] identID;
}
------解决方案--------------------struct userInfo
{
public string naem;
public string sex;
public string identID;
}
------解决方案--------------------你想问什么啊,问题说清楚点啊????????
------解决方案--------------------用string 就ok,超难谈不上
------解决方案--------------------struct userInfo
{
string name;
string sex;
string identID;
}
------解决方案-------------------- public struct UserInfo
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 50)]
public string name;
[ MarshalAs( UnmanagedType.ByValArray, SizeConst=8 )]
public string sex;
[ MarshalAs( UnmanagedType.ByValArray, SizeConst=18 )]
public string identID;
}
应该这样写
------解决方案--------------------struct userInfo
{
char[] naem;
char[] sex;
char[] identID;
}
------解决方案-------------------- public struct UserInfo
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 50)]
public string name;
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=8 )]
public string sex;
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=18 )]
public string identID;
}
改一下,呵呵
------解决方案--------------------mark
------解决方案--------------------struct userInfo
{
public static string name;
public static string sex;
public static string identID;
}
------解决方案--------------------最近也在看这些问题,希望用得上
public struct Basic_Info
{
public long SerialNo;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 7)]
public char[] ValidateTime;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=19)]
public char[] IdentityCard;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=13)]
public char[] ICCardNo;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=17)]