リンクVBFixedStringAttribute Classから気付く重要なことは
VBFixedStringAttribute は情報提供用であり、可変長文字列を固定文字列に変換するために使用することはできません。この属性の目的は、VBFixedStringAttribute を認識するメソッドまたは API 呼び出しによって、構造体および非ローカル変数内の文字列がどのように使用されるかを変更することです。この属性は、文字列自体の実際の長さを変更しないことに注意してください。
VB.Netから C# へ
Structure Person
Public ID As Integer
Public MonthlySalary As Decimal
Public LastReviewDate As Long
<VBFixedString(15)> Public FirstName As String
<VBFixedString(15)> Public LastName As String
<VBFixedString(15)> Public Title As String
<VBFixedString(150)> Public ReviewComments As String
End Structure
と同じです
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
struct Person
{
public int ID;
public decimal MonthlySalary;
public long LastReviewDate;
[VBFixedString(15)]
public string FirstName;
[VBFixedString(15)]
public string LastName;
[VBFixedString(15)]
public string Title;
[VBFixedString(150)]
public string ReviewComments;
}