System.DirectoryServices.PropertyCollectionをループしてプロパティ名と値を出力する方法の例は誰でも提供できますか?PropertyCollectionをループする方法
私はC#を使用しています。
@ JaredPar - PropertyCollectionには名前/値プロパティはありません。 PropertyNamesとValuesがあり、System.Collection.ICollectionと入力します。私は、PropertyCollectionオブジェクトを構成するベースラインオブジェクトタイプを知らない。
@JaredPar再び - 私はもともと誤ったタイプの質問に間違ったラベルを付けました。それは私の悪かった。
更新: Zhaph-Ben Duguidの入力に基づいて、次のコードを作成することができました。
using System.Collections;
using System.DirectoryServices;
public void DisplayValue(DirectoryEntry de)
{
if(de.Children != null)
{
foreach(DirectoryEntry child in de.Children)
{
PropertyCollection pc = child.Properties;
IDictionaryEnumerator ide = pc.GetEnumerator();
ide.Reset();
while(ide.MoveNext())
{
PropertyValueCollection pvc = ide.Entry.Value as PropertyValueCollection;
Console.WriteLine(string.Format("Name: {0}", ide.Entry.Key.ToString()));
Console.WriteLine(string.Format("Value: {0}", pvc.Value));
}
}
}
}
foreachループで暗黙の変換を使用する方が良いでしょう。 –