C# 如何将特定方法添加到当前类中

C# 如何将特定方法添加到当前类中,c#,C#,我的问题是。我有一个学校作业,要求我在给定的链接类中添加一个新方法,不允许我对当前的链接类进行任何更改 iii.removeparcelateposition(int n):此方法将删除链表中位置n处的节点。假设链表的第一个节点的位置号为1,第二个节点的位置号为2,依此类推 class LinkedList { private Node head; // first node in the linked list private int count; public i

我的问题是。我有一个学校作业,要求我在给定的链接类中添加一个新方法,不允许我对当前的链接类进行任何更改

iii.
removeparcelateposition(int n)
:此方法将删除链表中位置n处的节点。假设链表的第一个节点的位置号为1,第二个节点的位置号为2,依此类推

class LinkedList
{
    private Node head;  // first node in the linked list
    private int count;

    public int Count
    {
        get { return count; }
        set { count = value; }
    }

    public Node Head
    {
        get { return head; }
    }
    public LinkedList()
    {
        head = null;    // creates an empty linked list
        count = 0;
    }

public void AddFront(int n)
{
        Node newNode = new Node(n);
        newNode.Link = head;
        head = newNode;
        count++;

}

    public void DeleteFront()
    {
        if (count > 0)
        {
            Node temp = head;
            head = temp.Link;
            temp = null;
            count--;
        }
    }


}
也许你应该用

像这样的

namespace LinkedListExtension
{
    public static class MyExtensions
    {
        public static void RemoveParcelAtPosition(this LinkedList, int n)
        {
            // remove here
        }
    }   
}
此方法调用如下所示:

_yourLinkedList.RemoveParcelAtPosition(position);
使用继承。
使用所需的方法创建一个新类。继承
链接列表中的类。
类。

等等,什么?如何在不更改方法的情况下向类添加方法?也许你只是不允许更改其他方法?将类声明为
partial
对不起,我还在学习。我不知道分机是什么。请阅读遗嘱,谢谢!