.NET 框架类库
Array 方法请参见
Array 类 | System 命名空间
此处列出 Array 类的方法。有关 Array 类成员的完整列表,请参阅 Array 成员主题。
公共方法
BinarySearch 已重载。使用二进制搜索算法在一维的排序 Array 中搜索值。
Clear 将 Array 中的一系列元素设置为零、false 或空引用(Visual Basic 中为 Nothing),具体取决于元素类型。
Clone 创建 Array 的浅表副本。
Copy 已重载。将一个 Array 的一部分复制到另一个 Array 中,并根据需要执行强制类型转换和装箱。
CopyTo 将当前一维 Array 的所有元素复制到指定的一维 Array 中(从指定的目标 Array 索引开始)。
CreateInstance 已重载。初始化 Array 类的新实例。
Equals(从 Object 继承) 已重载。确定两个 Object 实例是否相等。
GetEnumerator 返回 Array 的 IEnumerator。
GetHashCode(从 Object 继承) 用作特定类型的哈希函数,适合在哈希算法和数据结构(如哈希表)中使用。
GetLength 获取 Array 的指定维度中的元素数。
GetLowerBound 获取 Array 中指定维度的下限。
GetType(从 Object 继承) 获取当前实例的 Type。
GetUpperBound 获取 Array 的指定维度的上限。
GetValue 已重载。获取当前 Array 中指定元素的值。
IndexOf 已重载。返回一维 Array 或部分 Array 中某个值第一个匹配项的索引。
Initialize 通过调用值类型的默认构造函数,初始化值类型 Array 的每一个元素。
LastIndexOf 已重载。返回一维 Array 或部分 Array 中某个值的最后一个匹配项的索引。
Reverse 已重载。反转一维 Array 或部分 Array 中元素的顺序。
SetValue 已重载。将当前 Array 中的指定元素设置为指定值。
Sort 已重载。对一维 Array 对象中的元素进行排序。
ToString(从 Object 继承) 返回表示当前 Object 的 String。
受保护的方法
Finalize(从 Object 继承) 已重写。允许 Object 在“垃圾回收”回收 Object 之前尝试释放资源并执行其他清理操作。
在 C# 和 C++ 中,使用析构函数语法来表示终结程序。
MemberwiseClone(从 Object 继承) 创建当前 Object 的浅表副本。
显式接口实现
IList.Add 实现 IList.Add。总是引发 NotSupportedException。
IList.Clear 将 Array 中的所有元素设置为零、false 或空引用(Visual Basic 中为 Nothing),具体取决于元素类型。
IList.Contains 确定某元素是否在 Array 中。
IList.IndexOf 搜索指定的对象,并返回当前一维实例中第一个匹配项的索引。
IList.Insert 实现 IList.Insert。总是引发 NotSupportedException。
IList.Remove 实现 IList.Remove。总是引发 NotSupportedException。
IList.RemoveAt 实现 IList.RemoveAt。总是引发 NotSupportedException。
请参见
Array 类 | System 命名空间
--------------------------------------------------------------------------------
将文档反馈发送给 Microsoft
© 2002 Microsoft Corporation。保留所有权利。
.NET 框架类库
TextBox 类 [C#]请参见
TextBox 成员 | System.Windows.Forms 命名空间 | TextBoxBase
要求
命名空间: System.Windows.Forms
平台: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family
程序集: System.Windows.Forms (在 System.Windows.Forms.dll 中)
语言
C#
C++
JScript
Visual Basic
全部显示
表示 Windows 文本框控件。
有关此类型所有成员的列表,请参阅 TextBox 成员。
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.TextBoxBase
System.Windows.Forms.TextBox
System.Windows.Forms.DataGridTextBox
[Visual Basic]
Public Class TextBox
Inherits TextBoxBase
[C#]
public class TextBox : TextBoxBase
[C++]
public __gc class TextBox : public TextBoxBase
[JScript]
public class TextBox extends TextBoxBase
线程安全
此类型的所有公共静态(Visual Basic 中为 Shared)成员对多线程操作而言都是安全的。但不保证任何实例成员是线程安全的。
备注
TextBox 控件允许用户在应用程序中输入文本。此控件具有标准 Windows 文本框控件所没有的附加功能,包括多行编辑和密码字符屏蔽。
通常,TextBox 控件用于显示单行文本或将单行文本作为输入来接受。可以使用 Multiline 和 ScrollBars 属性,从而能够显示或输入多行文本。通过将 AcceptsTab 和 AcceptsReturn 属性设置为 true,可在多行 TextBox 控件中更加灵活地操作文本。
通过将 MaxLength 属性设置为一个特定的字符数,可以限制输入到 TextBox 控件中的文本数量。TextBox 控件还可用于接受密码和其他敏感信息。可以使用 PasswordChar 属性屏蔽在控件的单行版本中输入的字符。
若要限制某些文本不被输入到 TextBox 控件,可以为 KeyDown 事件创建一个事件处理程序,以便验证在控件中输入的每个字符。也可以通过将 ReadOnly 属性设置为 true 来限制 TextBox 控件中的所有数据项输入,。
注意 TextBox 控件的大多数功能是从 TextBoxBase 类继承的。
示例
[Visual Basic, C#, JScript] 以下示例创建一个带垂直滚动条的多行 TextBox 控件。此示例使用 AcceptsTab、AcceptsReturn 和 WordWrap 属性来使多行文本框控件可用于创建文本文档。
[Visual Basic]
Private Sub CreateMyMultilineTextBox()
' Create an instance of a TextBox control.
Dim textBox1 As New TextBox()
' Set the Multiline property to true.
textBox1.Multiline = True
' Add vertical scroll bars to the TextBox control.
textBox1.ScrollBars = ScrollBars.Vertical
' Allow the RETURN key to be entered in the TextBox control.
textBox1.AcceptsReturn = True
' Allow the TAB key to be entered in the TextBox control.
textBox1.AcceptsTab = True
' Set WordWrap to True to allow text to wrap to the next line.
textBox1.WordWrap = True
' Set the default text of the control.
textBox1.Text = "Welcome!"
End Sub
[C#]
private void CreateMyMultilineTextBox()
{
// Create an instance of a TextBox control.
TextBox textBox1 = new TextBox();
// Set the Multiline property to true.
textBox1.Multiline = true;
// Add vertical scroll bars to the TextBox control.
textBox1.ScrollBars = ScrollBars.Vertical;
// Allow the RETURN key to be entered in the TextBox control.
textBox1.AcceptsReturn = true;
// Allow the TAB key to be entered in the TextBox control.
textBox1.AcceptsTab = true;
// Set WordWrap to True to allow text to wrap to the next line.
textBox1.WordWrap = true;
// Set the default text of the control.
textBox1.Text = "Welcome!";
}
[JScript]
private function CreateMyMultilineTextBox()
{
// Create an instance of a TextBox control
textBox1 = new TextBox();
// Set the Multiline property to true.
textBox1.Multiline = true;
// Add vertical scroll bars to the TextBox control.
textBox1.ScrollBars = ScrollBars.Vertical;
// Allow the RETURN key to be entered in the TextBox control.
textBox1.AcceptsReturn = true;
// Allow the TAB key to be entered in the TextBox control.
textBox1.AcceptsTab = true;
// Set WordWrap to True to allow text to wrap to the next line.
textBox1.WordWrap = true;
// Set the default text of the control.
textBox1.Text = "Welcome!";
}
[C++] 没有可用于 C++ 的示例。若要查看 Visual Basic、C# 或 JScript 示例,请单击页左上角的语言筛选器按钮 。
要求
命名空间: System.Windows.Forms
平台: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family
程序集: System.Windows.Forms (在 System.Windows.Forms.dll 中)
请参见
TextBox 成员 | System.Windows.Forms 命名空间 | TextBoxBase
--------------------------------------------------------------------------------
将文档反馈发送给 Microsoft
© 2002 Microsoft Corporation。保留所有权利。