C#程序设计基础
第一章 基本概念和语法(上)
1) VS.NET 2003 开发环境介绍
2) 第一个 C#程序
using System;
namespace ConsoleApp {
class Program {
static void Main(string[] args) {
Console.WriteLine( "Hello World" );
}
}
}
3) 数据类型
using System;
namespace DataTypeSample1 {
class Class2 {
}
interface Calculator {
void Plus();
void Decrease();
void Multiply();
void Devide();
}
class Class1 {
static void Main(string[] args) {
int a;
a = 3;
Console.WriteLine( "{0}",a.ToString());
string str = "Hello";
int b = 2005;
Console.WriteLine( "{0} CSharp {1}", str,
b.ToString());
double dz = 100.96;
string c = Console.ReadLine();
dz = dz + double.Parse( c ) ;
Console.WriteLine( "Double Z : {0} ", dz.ToString());
/// 数组的定义
string[] strings = new string[100];
}
}
}
4) 过程调用
using System;
namespace MethodSample1 {
class Class1 {
static void Main(string[] args) {
Class1.WriteMsg();
Class1.WriteName( " A Guang " );
}
public static void WriteMsg() {
Console.WriteLine( "Hello World ! ");
}
public static void WriteName( string Name ) {
Console.WriteLine( " Hello {0}", Name );
}
}