In a recent question, Import a VB6 structure into C#, the code contained a fixed-length string similar to this:
Name As String *10
There was some discussion in the question about how to implement a fixed-length string in C#, and I provided a possible method (though I recommended against using fixed-length strings in any form). However, one of the answers mentioned VBFixedStringAttribute, without further explanation and I was intrigued to find out what that was about. However, when I went looking for some information on it, I could find very little on MSDN or even in a Bing search. The question then is “How does one actually use this?”
I could find no C# code examples, and though there was a mimimal example of VB.NET on MSDN, my VB.NET skills are insufficient to figure out what was going on with it so I could translate it to C#.
Can someone provide a little code and explanation of what is going on with VBFixedStringAttribute?
I think the important thing to notice from the link VBFixedStringAttribute Class is
The VBFixedStringAttribute is informational and cannot be used to convert a variable length string to a fixed string. The purpose of this attribute is to modify how strings in structures and non-local variables are used by methods or API calls that recognize the VBFixedStringAttribute. Keep in mind that this attribute does not change the actual length of the string itself.
From VB.Net to C#
is the same as