Ok, the answer seems simple. Do not use classes
Stack
or
Queue
; they are almost useless or at least unsafe for your application. Instead, use
generic classes Stack<>
and
Queue<>
. In angular brackets, put actual compile-time type you want to have for element of your Queue or Stack.
If I understand your code, you will use:
Queue<patient> Queue = new Queue<patient>();
Stack<patient> Stack = new Stack<patient>();
Also, do yourself a favor, use standard naming conventions:
Patient
, not
patient
, because this is a type name.