推出几个C#简单源码?供初学者看看!

来源:互联网 发布:社会调查软件 编辑:程序博客网 时间:2024/06/05 13:22

using System; //引用了一个叫System的名空间
class HelloWorld  //定义一个叫HelloWorld的类
{
  public static void Main()  //静态的Main方法是程序的入口
  {
   Console.WriteLine("Hello, World!");  //输出Hello, World!
  }
}
 

using System;  //引用了一个叫System的名空间

class easyInput  //类的名字与文件名不同也无所谓
{
 public static void Main()
 {
  string strName;  //声明一个string类型的值变量
  Console.Write("please input your name:");  //输出一句话,但不换行
  strName = Console.ReadLine();  //从键盘读入用户的输入,回车表示输入结束
  Console.WriteLine("hello, {0}!", strName);  //格式化输出hello信息
 }
}