日期:2014-05-17 浏览次数:21146 次
using System;
class Hello
{
static void Main(){
Console.WriteLine("Hello world!");
}
}
using System;
class ArrayTest
{
static void Main(){
//int[] arr = new int[]{1,2,3};
int[] arr = {1,2,3};
//foreach(int i in arr){
//Console.WriteLine(i);
for(int i=0;i<arr.Length;i++){
Console.WriteLine(arr[i]);
Console.WriteLine("arr[{0}]={1}",i,arr[i]);
}
Console.WriteLine(Console.ReadLine());
}
}
using System;
using System.Collections;
class ArrList
{
static void Main(){
ArrayList arr = new ArrayList();
String str1;
while(true){
Console.WriteLine("please add a string to ArrayList:");
str1 = Console.ReadLine();
if(str1 == "end") break;
arr.Add(str1);
Console.WriteLine();
for(int i=0;i<arr.Count;i++)
Console.Write("{0}",arr[i]);
Console.WriteLine("\n");
}
}
}
using System;
class Matrix
{
static void Main(){
int[,] arr = new int[4,6];
for(int i=0;i<4;i++){
for(int j=0;j<6;j++){
arr[i,j] = (i+1)*10+j+1;
Console.Write("{0} ",arr[i,j]);
}
Console.WriteLine();
}
}
}
using System;
namespace CG
{
class Test
{
static void Main(){
Console.WriteLine("my namespance is CG");
A.A1.PrintName a = new A.A1.PrintName();
a.intro();
A.A2.PrintName b = new A.A2.PrintName();
b.intro();
}
}
}
namespace A
{
namespace A1
{
public class PrintName
{
public void intro(){
Console.WriteLine("My namespace is A1");
}
}
}
namespace A2
{
public class PrintName
{
public void intro(){
Console.WriteLine("My namespace is A2");
}
}
}
}
using System;
using A=ParentNamespace.ChildNamespace;
namespace CG
{
class Test
{
static void Main(){
//ParentNamespace.ChildNamespace.PrintNamespace print = new ParentNamespace.ChildNamespace.PrintNamespace();
A.PrintNamespace print = new A.PrintNamespace();
print.intro();
}
}
}
namespace ParentNamespace
{
namespace ChildNamespace
{
public class PrintNamespace
{
public void intro(){
Console.WriteLine("My name is namespace");
}
}
}
}
using System;
class Mathod
{
static void Main(){
Console.WriteLine("Now time is {0}",MyMethod());
}
public static DateTime MyMethod(){
return DateTime.Now;
}
}