It depends on what you are trying to do.
If you're just trying to create an appropriate structure, look at David Heffernan's answer. Nowadays there is little reason to compare two fields on top of each other, if they really do not represent the same thing. (Let's say individual elements or the same elements in an array.)
If you are actually trying to exchange files, you need to look at the ananthonline response lines, but there is a problem with this, which is big enough, I could not put it in a comment:
Not only a problem with Unicode, but also a short Delphi line does not have a corresponding structure in C #, and therefore it is impossible to simply map a field on top of it.
This line [20] actually contains 21 bytes, a single-byte length code, and 20 characters. You must follow the length code, as there is no guarantee that it is outside the specified length - you are likely to find trash there. (Hint: if the record will be written to disk, always loop the field before inserting new data into it. This greatly facilitates checking the file on disk during debugging.)
Thus, you need to declare two fields and write code to process it at both ends.
Since you still need to do this, I would go ahead and write code to handle the rest, to eliminate the need for unsafe code altogether.
source share