C#嵌套类
2021-01-25 00:12
标签:row using result cme bsp null try space div 顶层类是包含套嵌类的类。 C#嵌套类 标签:row using result cme bsp null try space div 原文地址:https://www.cnblogs.com/Tpf386/p/12038328.html
顶层类与套嵌类的关系十分密切,或套嵌类仅供顶层类使用时才推荐使用套嵌起来的方式。using System;
namespace Acme.Collections
{
public class Stack
{
Entry top;
public void Push(object data) {
top = new Entry(top, data);
}
public object Pop() {
if (top == null) throw new InvalidOperationException();
object result = top.data;
top = top.next;
return result;
}
class Entry
{
public Entry next;
public object data;
public Entry(Entry next, object data) {
this.next = next;
this.data = data;
}
}
}
}