本文整理汇总了C#中DoublyLinkedList.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# DoublyLinkedList.RemoveAt方法的具体用法?C# DoublyLinkedList.RemoveAt怎么用?C# DoublyLinkedList.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoublyLinkedList
的用法示例。
在下文中一共展示了DoublyLinkedList.RemoveAt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveAt
public void RemoveAt()
{
var list = new DoublyLinkedList<int>(new[] { 1, 2, 3 });
list.RemoveAt(1);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(1, list[0].Value);
Assert.AreEqual(3, list[1].Value);
}
示例2: TestDoublyLinkedListRemoveAt
public void TestDoublyLinkedListRemoveAt()
{
DoublyLinkedList<string> list = new DoublyLinkedList<string>();
list.Add("One");
list.Add("Two");
list.Add("Three");
list[0] = "Zero";
list.RemoveAt(1);
string[] array = new string[list.Count];
list.CopyTo(array);
Assert.AreEqual("Zero, Three", string.Join(", ", array));
}
示例3: Main
static void Main(string[] args)
{
try
{
DoublyLinkedList<Person> list = new DoublyLinkedList<Person>();
list.AddFirst(new Person("Nikita Vasilyev", 24));
list.AddFirst(new Person("Bill Gates", 59));
list.AddFirst(new Person("Muhhamed Ali", 76));
list.AddLast(new Person("Lennox Lewis", 46));
list.InsertAt(new Person("Steve Jobs", 54), 2);
list.Show();
list.RemoveAt(4);
Console.WriteLine(list[2]);
Person p = new Person("Nikita Vasilyev", 24);
Console.WriteLine(list.Find(p));
list.FindLast(p).FullName = "Nikita V. Vasilyev";
list.ShowReverse();
list.Show();
}
catch (IndexOutOfRangeException ex)
{
Console.WriteLine("Message:\t" + ex.Message);
Console.WriteLine("Method:\t\t" + ex.TargetSite);
}
catch (ArgumentNullException ex)
{
Console.WriteLine("Message:\t" + ex.Message);
Console.WriteLine("Method:\t\t" + ex.TargetSite);
}
catch (InvalidOperationException ex)
{
Console.WriteLine("Message:\t" + ex.Message);
Console.WriteLine("Method:\t\t" + ex.TargetSite);
}
catch (Exception ex)
{
Console.WriteLine("Message:\t" + ex.Message);
Console.WriteLine("Method:\t\t" + ex.TargetSite);
}
}
示例4: Traverse
public void Traverse()
{
var list = new DoublyLinkedList<int>(new[] { 1, 2, 3 });
// Perform various operations
list.AddFirst(0);
list.RemoveFirst();
list.AddLast(0);
list.RemoveLast();
list.Insert(1, 0);
list.RemoveAt(1);
var current = list.First;
while (current.Next != null)
{
current = current.Next;
}
Assert.AreEqual(list.Last, current);
while (current.Previous != null)
{
current = current.Previous;
}
Assert.AreEqual(list.First, current);
}