using System;
class Test
{
  static void F(params int[]args)
  {
      Console.WriteLine("# of argument:{0}",args.Length);
      for(int i=0;i<args.Length;i++)
          Console.WriteLine("\targs[{0}]={1}",i,args[i]);
  }
  static void Main()
  {
      F();//没有参数,默认传递的是 new int[0],但不是null
      F(1);
      F(1, 2);
      F(1, 2, 3);
      F(new int[] { 1, 2, 3, 4 });
  }
}

 

using System;
public class Stack
{
    private Node first = null;
    public bool Empty
    {
        get
        {
            return (first == null);
        }
    }
    public object Pop()
    {
        if (first == null)
            throw new Exception("Can't Pop from an empty Stack.");
        else
        {
            object temp = first.Value;
            first = first.Next;
            return temp;
        }
    }
    public void push(object o)
    {
        first = new Node(o, first);
    }
    class Node
    {
        public Node Next;
        public object Value;
        public Node(object value) : this(value, null) { }
        public Node(object value,Node next)
        {
            Next = next;
            Value = value;
        }
    }
}

 

相关文章:

  • 2022-01-12
  • 2022-12-23
  • 2022-01-23
  • 2021-08-27
  • 2021-05-08
  • 2021-10-01
  • 2021-05-17
  • 2021-08-08
猜你喜欢
  • 2021-10-16
  • 2021-08-13
  • 2021-11-29
  • 2021-12-03
相关资源
相似解决方案