NameValueCollection.Get 方法

定义

获取 NameValueCollection 中指定项的值,这些值已合并为一个以逗号分隔的列表。Gets the values of a specified entry in the NameValueCollection combined into one comma-separated list.

重载

Get(Int32)

获取 NameValueCollection 中指定索引处的值,这些值已合并为一个以逗号分隔的列表。Gets the values at the specified index of the NameValueCollection combined into one comma-separated list.

Get(String)

获取与 NameValueCollection 中的指定键关联的值,这些值已合并为一个以逗号分隔的列表。Gets the values associated with the specified key from the NameValueCollection combined into one comma-separated list.

Get(Int32)

获取 NameValueCollection 中指定索引处的值,这些值已合并为一个以逗号分隔的列表。Gets the values at the specified index of the NameValueCollection combined into one comma-separated list.

public:
 virtual System::String ^ Get(int index);
public virtual string Get (int index);
public virtual string? Get (int index);
abstract member Get : int -> string
override this.Get : int -> string
Public Overridable Function Get (index As Integer) As String

参数

index
Int32

项的从零开始的索引,该项包含要从集合中获取的值。The zero-based index of the entry that contains the values to get from the collection.

返回

String

如果找到,则为一个 String,包含 NameValueCollection 中指定索引处的值的列表(此列表以逗号分隔);否则为 nullA String that contains a comma-separated list of the values at the specified index of the NameValueCollection, if found; otherwise, null.

例外

index 超出了集合的有效索引范围。index is outside the valid range of indexes for the collection.

注解

此方法是一个 O (n) 操作,其中, n 是指定索引处的值的数目。This method is an O(n) operation, where n is the number of values at the specified index.

另请参阅

适用于

Get(String)

获取与 NameValueCollection 中的指定键关联的值,这些值已合并为一个以逗号分隔的列表。Gets the values associated with the specified key from the NameValueCollection combined into one comma-separated list.

public:
 virtual System::String ^ Get(System::String ^ name);
public virtual string Get (string name);
public virtual string? Get (string? name);
abstract member Get : string -> string
override this.Get : string -> string
Public Overridable Function Get (name As String) As String

参数

name
String

项的 String 键,该项包含要获取的值。The String key of the entry that contains the values to get. 键可以是 nullThe key can be null.

返回

String

如果找到,则为一个 String,包含与 NameValueCollection 中的指定键关联的值的列表(此列表以逗号分隔);否则为 nullA String that contains a comma-separated list of the values associated with the specified key from the NameValueCollection, if found; otherwise, null.

注解

注意

如果找不到指定的键,则此方法 null 在以下情况下返回: 1) ; 如果找到指定的键,则为 2) ; 如果找到指定的值,则为 2 nullThis method returns null in the following cases: 1) if the specified key is not found; and 2) if the specified key is found and its associated value is null. 此方法不区分这两种情况。This method does not distinguish between the two cases.

此方法是一个 (n) 操作的 O,其中 n 是与指定键关联的值的数目。This method is an O(n) operation, where n is the number of values associated with the specified key.

另请参阅

适用于