赞
踩
- static void Main(){
- }
- int var1 = 5;
- System.Console.WriteLine("The value of var1 is {0}",var1);
- {
- int var1 = 5;
- System.Console.WriteLine("The value of var1 is {0}",var1);
- }
- System.Console.WriteLine("Hello world1.");
- System.Console.WriteLine("Hello world2.");
- System.Console.WriteLine("Hello world3.");
Console.WriteLine("两个数相加{0}+{1}={2}",3,34,34);
Console.WriteLine("Three integers are {1},{0} and {1}",3,5);
- int age;
- int hp;
- string name;
int age ;
age = 25;
int age = 25;
string name1,name2;
- enum <typeName>{
- <value1>,
- <value2>,
- <value3>,
- .....
- <valueN>
- }
- enum WeekDay
- { Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday }
- WeekDay day;
- namespace CalculatorApplication
- {
- class NumberManipulator
- {
- public int factorial(int num)
- {
- /* 局部变量定义 */
- int result;
- if (num == 1)
- {
- return 1;
- }
- else
- {
- result = factorial(num - 1) * num;
- return result;
- }
- }
-
- static void Main(string[] args)
- {
- NumberManipulator n = new NumberManipulator();
- //调用 factorial 方法
- Console.WriteLine("6 的阶乘是: {0}", n.factorial(6));
- Console.WriteLine("7 的阶乘是: {0}", n.factorial(7));
- Console.WriteLine("8 的阶乘是: {0}", n.factorial(8));
- Console.ReadLine();
- }
- }
- }

double[] balance;
double[] balance = new double[10];
- double[] balance = new double[10];
- balance[0] = 4500.0;
double[] balance = { 2340.0, 4523.69, 3421.0};
int [] marks = new int[5] { 99, 98, 92, 97, 95};
int [] marks = new int[] { 99, 98, 92, 97, 95};
- int [] marks = new int[] { 99, 98, 92, 97, 95};
- int[] score = marks;
- using System;
- namespace ArrayApplication
- {
- class MyArray
- {
- static void Main(string[] args)
- {
- int [] n = new int[10]; /* n 是一个带有 10 个整数的数组 */
- int i,j;
- /* 初始化数组 n 中的元素 */
- for ( i = 0; i < 10; i++ )
- {
- n[ i ] = i + 100;
- }
- /* 输出每个数组元素的值 */
- for (j = 0; j < 10; j++ )
- {
- Console.WriteLine("Element[{0}] = {1}", j, n[j]);
- }
- Console.ReadKey();
- }
- }
- }

- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Test01
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] arr = { 1, 2, 3, 4, 5 }; //定义一个一维数组,并为其赋值
- foreach (int n in arr) //使用foreach语句循环遍历一维数组中的元素
- Console.WriteLine("{0}", n + " ");
- Console.WriteLine();
- }
- }
- }

int[,]arr=newint[2,2];
int[,]arr=newint[2,2]{{1,2},{3,4}};
int[,]arr=newint[,]{{1,2},{3,4}};
- int [] l={1,2,3};
- int [] l2=1;
- l[0]=9;
- Console.WriteLine("l2[0]"+l2[0]);
- class MyDerivedClass: MyBaseClass
- {
- // functions and data members here
- }
- public class MyDerivedClass: MyBaseC1ass, IInterface1, IInterface2
- {
- // etc.
- }
- public struct MyDerivedstruct: IInterface1, IInterface2
- {
- // etc.
- }
- /// <summary>
- /// 狗(多态:重载事例)
- /// </summary>
- class Dog
- {
- /// <summary>
- /// 叫
- /// </summary>
- public void Shout()
- {
- Console.WriteLine("汪!");
- }
- /// <summary>
- /// 叫(重载方法)
- /// </summary>
- public void Shout(int count)
- {
- int i = 0;
- string shout = "";
- do
- {
- shout += "汪!";
- i++;
- } while (i <= count);
- Console.WriteLine(shout);
- }
- }
-

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。