本文整理汇总了C#中Grid.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.Remove方法的具体用法?C# Grid.Remove怎么用?C# Grid.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grid
的用法示例。
在下文中一共展示了Grid.Remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Basics
[Test] public void Basics()
{
Grid<int> grid = new Grid<int>(2, 2);
grid[0, 0] = 0;
grid[1, 0] = 1;
grid[0, 1] = 2;
grid[1, 1] = 3;
Assert.AreEqual(4, grid.Capacity);
Assert.AreEqual(2, grid.Width);
Assert.AreEqual(2, grid.Height);
CollectionAssert.AreEqual(new[] {
0, 1,
2, 3 }, grid);
Assert.IsTrue(grid.Contains(3));
Assert.AreEqual(new Point2(1, 1), grid.IndexOf(3));
Assert.IsTrue(grid.Remove(3));
Assert.IsFalse(grid.Remove(3));
Assert.IsFalse(grid.Contains(3));
Assert.AreEqual(new Point2(-1, -1), grid.IndexOf(3));
CollectionAssert.AreEqual(new[] {
0, 1,
2, 0 }, grid);
grid.Resize(4, 4, Alignment.Center);
Assert.AreEqual(16, grid.Capacity);
Assert.AreEqual(4, grid.Width);
Assert.AreEqual(4, grid.Height);
CollectionAssert.AreEqual(new[] {
0, 0, 0, 0,
0, 0, 1, 0,
0, 2, 0, 0,
0, 0, 0, 0 }, grid);
grid.ShrinkToFit();
CollectionAssert.AreEqual(new[] {
0, 1,
2, 0 }, grid);
grid.Clear();
CollectionAssert.AreEqual(Enumerable.Repeat(0, grid.Capacity), grid);
}
示例2: Objects
[Test] public void Objects()
{
Grid<string> grid = new Grid<string>(2, 2);
grid[0, 0] = "Cell A";
grid[1, 0] = "Cell B";
grid[0, 1] = "Cell C";
grid[1, 1] = "Cell D";
grid.Remove("Cell B");
Assert.AreEqual(null, grid[1, 0]);
}