本文整理汇总了C#中TreeNodeCollection.ForEach方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNodeCollection.ForEach方法的具体用法?C# TreeNodeCollection.ForEach怎么用?C# TreeNodeCollection.ForEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNodeCollection
的用法示例。
在下文中一共展示了TreeNodeCollection.ForEach方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IterationTestCase
public void IterationTestCase()
{
var parent = new TreeNode<String>();
var target = new TreeNodeCollection<String>( parent )
{
"test1",
new TreeNode<String>( "test2" ),
"test3",
new TreeNode<String>( "test4" )
};
target.ForEach( ( x, i ) => Assert.AreEqual( "test" + ( i + 1 ), x.Value ) );
}
示例2: ParentTestCase5
public void ParentTestCase5()
{
var target = new TreeNodeCollection<String>( null ) { "1", "2" };
Assert.IsNull( target.Parent );
target.ForEach( x => Assert.IsNull( x.Parent ) );
var parent = new TreeNode<String>();
target.Parent = parent;
Assert.AreSame( parent, target.Parent );
target.ForEach( x => Assert.AreSame( parent, x.Parent ) );
target.Add( "3" );
target.Add( "4" );
target.ForEach( x => Assert.AreSame( parent, x.Parent ) );
ITreeNode<String> newParent = null;
target.Parent = newParent;
Assert.AreSame( newParent, target.Parent );
target.ForEach( x => Assert.AreSame( newParent, x.Parent ) );
}
示例3: DetachFromParentTestCase1
public void DetachFromParentTestCase1()
{
var parent = new TreeNode<String>();
var target = new TreeNodeCollection<String>( parent ) { "1", "2", "3" };
Assert.AreEqual( 3, target.Count );
target.ForEach( x => Assert.AreSame( parent, x.Parent ) );
target.DetachFromParent();
Assert.IsNull( target.Parent );
target.ForEach( x => Assert.IsNull( x.Parent ) );
}