C#时尚百例

来源:互联网 发布:产品摄影要点知乎 编辑:程序博客网 时间:2024/04/28 12:04

例子一
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信息
 }
}

原创粉丝点击