孤独的猫

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

2011年5月5日

摘要: 齿形数组时数组的一类,它的行也是数组---行数组中的元素个数可以不同。如string[][] names;接着names=new string[4][],创建了四个数组,它们的元素时字符串数组names[0]=new string[3]names[0][0]="Jason";names[0][1]="Marcus";names[0][2]="Price";names[1]=new string[2];names[0][0]="Steve";names[0][1]="Smith";例:/* Exa 阅读全文
posted @ 2011-05-05 21:39 孤独的猫 阅读(296) 评论(0) 推荐(0)

摘要: /* Example10_8.cs illustrates the use of a three-dimensional rectangular array*/using System;class Example10_8{ public static void Main() { // create the galaxy array int[,,] galaxy = new int [10, 5, 3]; // set two galaxy array elements to the star's brightness galaxy[1, 3, 2] = 3; galaxy[4, 1, 阅读全文
posted @ 2011-05-05 21:35 孤独的猫 阅读(275) 评论(0) 推荐(0)

摘要: C#中定义一个数组的方法一般为:DataType[]Array=newDataType[Size];其中DataType可以是基本数据类型和对象类型数据,Size是数组元素的个数.例子定义一个int类型的数据来表示一个班上的人数int[]classNum=newint[20];数组的属性有:属性意义publicvirtualboolIsFixedSize数组的长度是否是固定的publicvirtualboolIsReadOnly数组是否是只读型publicvirtualboolIsSynchronized在多线程环境下是否安全publicintLength数组元素的个数publicintRan 阅读全文
posted @ 2011-05-05 21:30 孤独的猫 阅读(282) 评论(0) 推荐(0)

摘要: /* Example9_4.cs illustrates the use of DateTime properties and methods*/using System;class Example9_4{ public static void Main() { // use the Now and UtcNow properties to get the currrent // date and time Console.WriteLine("DateTime.Now = " + DateTime.Now); Console.WriteLine("DateTim 阅读全文
posted @ 2011-05-05 21:22 孤独的猫 阅读(740) 评论(0) 推荐(0)

摘要: using System;using System.Linq;using System.Collections.Generic;class Exapmple1_1{ static void Main() { string[] names={"Burke","Connor","Frank", "Everett","Albert","George"}; IEnumerable<string> expr = from s in names where s.Length 阅读全文
posted @ 2011-05-05 21:05 孤独的猫 阅读(200) 评论(0) 推荐(0)

摘要: /* Example9_3.cs illustrates the use of DateTime and TimeSpan instances*/using System;class Example9_3{ public static void DisplayDateTime( string name, DateTime myDateTime ) { Console.WriteLine(name + " = " + myDateTime); // display the DateTime's properties Console.WriteLine(name + & 阅读全文
posted @ 2011-05-05 20:54 孤独的猫 阅读(698) 评论(0) 推荐(0)

摘要: System.Text.StringBuilder可以动态创建字符串。同String类中一般的字符串不同,动态字符串的字符可以直接修改,在一般的字符串中,修改的总是字符串的拷贝。同时StringBuilder方法效率更高并且提供了更有效的字符串操作能力。 /* Example9_2.cs illustrates the use of StringBuilder objects*/using System;using System.Text;class Example9_2{ public static void DisplayProperties( string name, StringBui 阅读全文
posted @ 2011-05-05 20:53 孤独的猫 阅读(387) 评论(0) 推荐(0)

摘要: sort命令主要用于文本排序,现有以文本文件video.txt$cat video.txtBoys in Company C:HK:192:2192Alien:HK:119:1982The Hill:KL:63:2972Aliens:HK:532:4892Star Wars:HK:301:4102A Few Good Men:KL:445:5851Toy Story:HK:239:3972将此文本按字母从小到大的顺序排序并输出到results.outsort video.txt >results.out再查看results.out,得到A Few Good Men:KL:445:5851 阅读全文
posted @ 2011-05-05 20:11 孤独的猫 阅读(363) 评论(0) 推荐(0)

摘要: #!/bin/sh C=([3]=77 [1]=100 [5]=66) echo ${C[5]}echo ${C[@]} #取出所有元素 阅读全文
posted @ 2011-05-05 19:47 孤独的猫 阅读(172) 评论(0) 推荐(0)

摘要: 可以在shell中强制必须声明变量,shopt 指令,如下面的指令mustpreset.sh 运行结果为50#!/bin/shdeclare Informix=50echo $Informix注意:在ubuntu中,运行此脚本需用 $bash mustpreset.sh,因为默认的sh版本为dash,不是bash如果脚本如下,会报错,因为没有事先声明变量shopt -s -o nounsetecho $test 阅读全文
posted @ 2011-05-05 19:32 孤独的猫 阅读(361) 评论(0) 推荐(0)