ConfigurationLockCollection.SetFromList(String) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
根據所提供的清單鎖定一組配置物件。
public:
void SetFromList(System::String ^ attributeList);
public void SetFromList(string attributeList);
member this.SetFromList : string -> unit
Public Sub SetFromList (attributeList As String)
參數
- attributeList
- String
一個逗號分隔的字串。
例外狀況
當參數 attributeList 中的某項不是有效的可鎖定配置屬性時,會發生這種情況。
範例
以下程式碼範例示範如何使用此 SetFromList 方法。 此程式碼範例是本類別更大範例 ConfigurationLockCollection 的一部分。
// Create an ArrayList to contain
// the property items of the configuration
// section.
ArrayList configPropertyAL = new ArrayList(lockedAttribList.Count);
foreach (PropertyInformation propertyItem in
configSection.ElementInformation.Properties)
{
configPropertyAL.Add(propertyItem.Name.ToString());
}
// Copy the elements of the ArrayList to a string array.
String[] myArr = (String[])configPropertyAL.ToArray(typeof(string));
// Create as a comma delimited list.
string propList = string.Join(",", myArr);
// Lock the items in the list.
lockedAttribList.SetFromList(propList);
' Create an ArrayList to contain
' the property items of the configuration
' section.
Dim configPropertyAL As ArrayList = _
New ArrayList(lockedAttribList.Count)
For Each propertyItem As _
PropertyInformation In _
configSection.ElementInformation.Properties
configPropertyAL.Add(propertyItem.Name.ToString())
Next
' Copy the elements of the ArrayList to a string array.
Dim myArr As [String]() = _
CType(configPropertyAL.ToArray(GetType(String)), [String]())
' Create as a comma delimited list.
Dim propList As String = String.Join(",", myArr)
' Lock the items in the list.
lockedAttribList.SetFromList(propList)