FixedLengthString 類別

定義

警告

此 API 現已淘汰。

模擬 Visual Basic 6.0 固定長度字串的行為。Emulates the behavior of a Visual Basic 6.0 fixed-length string.

public ref class FixedLengthString
[System.Obsolete("Microsoft.VisualBasic.Compatibility.* classes are obsolete and supported within 32 bit processes only. https://go.microsoft.com/fwlink/?linkid=160862")]
public class FixedLengthString
type FixedLengthString = class
Public Class FixedLengthString
繼承
FixedLengthString
屬性

範例

下列範例示範如何宣告和使用 FixedLengthStringThe following example demonstrates how to declare and use 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 中,可以使用固定的長度來宣告 StringIn Visual Basic 6.0, a String could be declared with a fixed length. 在 Visual Basic 中,已不再支援固定長度的字串,而且每次 String 的長度變更時,都會配置新的 StringIn Visual Basic, fixed-length strings are no longer supported and a new String is allocated every time the length of the String is changed.

FixedLengthString 類別可以用來模擬 Visual Basic 6.0 字串的行為,這可讓您宣告固定長度的字串。The FixedLengthString class can be used to emulate the behavior of a Visual Basic 6.0 string, which enables you to declare a string with a fixed length. FixedLengthString 無法轉換成 String;您必須參考 Value 屬性,或呼叫 ToString 方法來轉換此類型。A FixedLengthString cannot be converted to a String; you must either reference the Value property or call the ToString method to convert the type.

注意

Microsoft.VisualBasic.Compatibility.VB6 命名空間中的函式和物件都是供這些工具使用,以便從 Visual Basic 6.0 升級至 Visual Basic 2008。Functions and objects in the Microsoft.VisualBasic.Compatibility.VB6 namespace are provided for use by the tools for upgrading from Visual Basic 6.0 to Visual Basic 2008. 在大多數情況下,這些函式和物件會複製在 .NET Framework 其他命名空間中可以找到的功能。In most cases, these functions and objects duplicate functionality that you can find in other namespaces in the .NET Framework. 只有當 Visual Basic 6.0 程式碼模型與 .NET Framework 實作有顯著差異時,才會需要這些函式和物件。They are necessary only when the Visual Basic 6.0 code model differs significantly from the .NET Framework implementation.

建構函式

FixedLengthString(Int32)

初始化 FixedLengthString 類別的新執行個體,並指定長度。Initializes a new instance of the FixedLengthString class, specifying the length.

FixedLengthString(Int32, String)

初始化 FixedLengthString 類別的新執行個體,並指定長度和初始值。Initializes a new instance of the FixedLengthString class, specifying the length and the initial value.

欄位

m_nMaxChars

儲存 FixedLengthString 的長度。Stores the length of a FixedLengthString.

m_strValue

儲存 FixedLengthString 的值。Stores the value of a FixedLengthString.

屬性

Value

取得或設定 FixedLengthString 的內容。Gets or sets the contents of a FixedLengthString.

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

FixedLengthString 轉換成 StringConverts a FixedLengthString to a String.

適用於