I can't check it in VS 2013 - it says my licence is "stale" and it can't retrieve a new one - but if I try it in VS 2022 it works fine converted to C#:
[StructLayout(LayoutKind.Explicit)]
public struct Foo
{
[FieldOffset(0)]
public int NameLength;
[FieldOffset(4), MarshalAs(UnmanagedType.LPStr, SizeConst = 50)] public string Name;
[FieldOffset(54)] public int Age;
}
But in VB, it gives me an error that a ">" is missing:
<FieldOffset(54)) Public Age As Integer
^
Which says that the code you are getting the error from isn;t the code you showed us - that won't compile so even if you did change it to "52" you'd still get an error.
Correct it, and I get no errors at all:
Public Structure Foo
<FieldOffset(0)> Public NameLength As Integer
<FieldOffset(4), MarshalAs(UnmanagedType.LPStr, SizeConst:=50)> Public Name As String
<FieldOffset(54)> Public Age As Integer
End Structure