FixedLengthString 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 FixedLengthString 类的新实例。
重载
| 名称 | 说明 |
|---|---|
| FixedLengthString(Int32) |
初始化类的新实例 FixedLengthString ,指定长度。 |
| FixedLengthString(Int32, String) |
初始化类的新实例 FixedLengthString ,指定长度和初始值。 |
FixedLengthString(Int32)
初始化类的新实例 FixedLengthString ,指定长度。
public:
FixedLengthString(int MaxChars);
public FixedLengthString(int MaxChars);
new Microsoft.VisualBasic.Compatibility.VB6.FixedLengthString : int -> Microsoft.VisualBasic.Compatibility.VB6.FixedLengthString
Public Sub New (MaxChars As Integer)
参数
- MaxChars
- Int32
一个指定字符串长度的字符串 Integer 。
示例
下面的示例演示如何声明和使用 a FixedLengthString.
Private Sub DemoFixedLengthString()
' Declare a string that has a length of 7 characters.
Dim fixedString As New FixedLengthString(7)
' Assign a value to the string.
fixedString.Value = "Hello World"
' Display the string in a message box.
' Note that only the first 7 characters are shown.
MsgBox(fixedString.ToString)
End Sub
注解
在 Visual Basic 6.0 中,可以在字符串声明中指定字符串的长度。 在Visual Basic中,除非在声明中使用 VBFixedStringAttribute 属性,否则不能声明字符串具有固定长度。
使用此类可以声明固定长度的字符串,而无需使用该属性。
注释
Microsoft.VisualBasic.Compatibility.VB6 命名空间中的函数和对象由用于从 Visual Basic 6.0 升级到 Visual Basic 2008 的工具使用。 在大多数情况下,这些函数和对象重复了可在 .NET Framework 中的其他命名空间中找到的功能。 仅当 Visual Basic 6.0 代码模型与 .NET Framework 实现明显不同时,它们才是必需的。
适用于
FixedLengthString(Int32, String)
初始化类的新实例 FixedLengthString ,指定长度和初始值。
public:
FixedLengthString(int MaxChars, System::String ^ InitialValue);
public FixedLengthString(int MaxChars, string InitialValue);
new Microsoft.VisualBasic.Compatibility.VB6.FixedLengthString : int * string -> Microsoft.VisualBasic.Compatibility.VB6.FixedLengthString
Public Sub New (MaxChars As Integer, InitialValue As String)
参数
- MaxChars
- Int32
一个指定字符串长度的字符串 Integer 。
示例
下面的示例演示如何声明和使用 a FixedLengthString.
Private Sub DemoFixedLengthString()
' Declare a string that has a length of 7 characters and assign the
' initial string. The additional 5 positions will be padded with
' spaces.
Dim fixedString As New FixedLengthString(7, "He")
' Display the string in a message box.
MsgBox(fixedString.ToString)
' Assign a new value to the string.
fixedString.Value = "Hello World"
' Display again. Note that only the first 7 characters are shown.
MsgBox(fixedString.ToString)
End Sub
注解
在 Visual Basic 6.0 中,可以在字符串声明中指定字符串的长度。 在Visual Basic中,除非在声明中使用 VBFixedStringAttribute 属性,否则不能声明字符串具有固定长度。
使用此类可以声明固定长度字符串,而无需使用特性。
注释
Microsoft.VisualBasic.Compatibility.VB6 命名空间中的函数和对象由用于从 Visual Basic 6.0 升级到 Visual Basic 2008 的工具使用。 在大多数情况下,这些函数和对象重复了可在 .NET Framework 中的其他命名空间中找到的功能。 仅当 Visual Basic 6.0 代码模型与 .NET Framework 实现明显不同时,它们才是必需的。