Sets the String value associated with the first occurrence of the specified String key.

Namespace: CodeSmith.CustomProperties
Assembly: CodeSmith.CustomProperties (in CodeSmith.CustomProperties.dll) Version: 6.0.0.0 (7.0.0.15127)

Syntax

C#
public virtual int SetByKey(
	string key,
	string value
)
Visual Basic
Public Overridable Function SetByKey ( 
	key As String,
	value As String
) As Integer

Parameters

key
Type: System..::..String
The String key whose value to set.
value
Type: System..::..String
The String object to associate with the first occurrence of the specified key. This argument can be a null reference. If the specified key is not found, SetByKey adds a new element with the specified key and value to the end of the NameValueCollection.

Return Value

Type: Int32
The NameValueCollection index of the element that was changed or added.

Remarks

SetByKey and GetByKey(String) emulate the indexer of the SortedList class but require linear time to locate a key.

Exceptions

ExceptionCondition
System..::..ArgumentNullExceptionkey is a null reference.
System..::..NotSupportedException

The NameValueCollection is read-only.

-or-

key does not exist in the collection, and the NameValueCollection has a fixed size.

See Also