当前位置:编程学习 > C#/ASP.NET >>

c#代码示例

要一些简单的windows应用程序源码。入门级别用的。
追问:抱歉 我想要windows应用程序的示例。 有windows窗体的那种。
     如果通过click事件获取窗体上的label控件。如何在窗体间传递参数,之类的。
答案:using System;   class Hello {   static void Main() {   Console.WriteLine("Hello, world");   Console.ReadLine();   } 

  }

 

这个是最简单的

下面这个是链表

public class Node
{
    private object Element;
    public Node Link;
    public Node()
    {
        Element = null;
        Link = null;
    }
    public Node(object theElement)
    {
        Element = theElement;
        Link = null;
    }
    public void AddNode(object theElement)
    {
        Link = new Node(theElement);
    }
    public void AddNode(Node n)
    {
        Link = n;
    }
    public override string ToString()
    {
        return Element.ToString();
    }
}
public class LinkedList
{
    public Node header;
    private Node current;
    public LinkedList()
    {
        header = new Node("header");
        current = header;
    }
    public void Add(Node n)
    {
        current.AddNode(n);
        current = current.Link;
    }
    public void Add(object obj)
    {
        current.AddNode(obj);
        current = current.Link;
    }
}

这个是堆栈

using System;
using System.Collections ;
namespace 栈的进入和弹出
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main(string[] args)
  {
   Stack colorStack=new Stack();
            colorStack.Push("red");
            colorStack.Push("green");
   colorStack.Push("blue");
   colorStack.Push("yellow");
   colorStack.Push("orange");
   Console.WriteLine ("栈中内容包括");
   foreach(string color in colorStack){
   Console.WriteLine(color);
   }
   while(colorStack.Count>0){
   string color=(string)colorStack.Pop();
    Console.WriteLine("弹出{0}",color);
                   }
   Console.WriteLine("结束");
   Console.ReadLine();
  }
}
}

上一个:C#操作数据库
下一个:C#HttpWebRequest使用

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,