C#基本类型库•集合和数组1.以下的C#程序:运行后数组A中的数值为()。
public static void Main() {int[] A=new intf51{ 1,2, 3,4,5 };Objectf l B = new Object[习{ 6, 7, & 9, 10 };Array.Copy( A, B、2 ); }a) 1、2、3、4、5b) 1、28、9、10c)1、2、3、9、10d )6、7、8、9、102.以下的C#程序:运行输出为()。
using System;using System.Collections;public class SamplesHashtable{public static void Main() {Hashtable myHT = new Hashtable(); myHT.Add(”A”, ”AA”);myHT.Add(”B”, ”BB“);myHT.Add(”C”,”CC“);Console.WriteLine(myHT.Count); myHT.Remove(” BB“);Console.WriteLine(myHT.Count);1}a)3 3b)3 2c)2 2d)运行时错误,提示无效的键值3.在.Net屮,ArrayList对象位于()命名空间内。
a)System.Arrayb)System.IOc)System.CoHectiond)System.RunTime4.阅读以下的C#代码:Class ClassiPublic static void doArr(int[J arr,out int k)程序最后运行结果为arr[2,l]的值:9 ,arr[2,l]的值:4 , arr[2J]的值:9 , a> b> ()(选一项) arrRank 的值为: arrRank 的值为: arrRank 的值为: arr[2,l]的值:9 , arrRank 的值为:2 213K=arr.Rank;for(int i=O;i<arr.GetLength(O);i++)For(int j=O;j<arr.GetLength( 1 );j++) {arr[i,j]=i+j+arr[i,j];}1}Static void Main(string[] args){int[,] arrl =new int[3,2] {{1,2},{3,4},{5,6}};int arrRank;Class 1 .do Arr(arr 1 .out arrRank);Console.WriteLine(t4an[2,1 ]的值:{0), anRank 的值为:{1}”, arr[2,l],arrRank); Console.ReadLine();5. 阅读以下的C#代码: namespace t4 3{public delegate int[] aDel(int[] arrl);class delfun{pub Iic int[] ArrayRev (int[] arrl) {Array. Reverse(arrl);return arrl;class Classi{static void main(string[] args) {int[] array1 = new int[5]; del fun funobj= new delfun ();aDel DelObj;for (int cnt 二0; cnt<5; cnt++){array1[cnt]=cnt * 2;}DelObj = new aDel (funobj. ArrayRev);Array1 = DelObj(arrayl);foreach(int y in arrayl){Console. WriteLine(y);}Console・ ReadLine();代码运行结果为()A)输出:0, 1,2, 3,4B)输出:0, 2, 4, 6, 80 输出:8, 6, 4, 2, 0D)以上都不正确6.针对下面的C#代码:Using System;Using System.Collections;Public calss SimpleArrayList{Public static void Main(){ArrayList myList = new ArrayList();For(int a = 1; a <= 20; a++){myList. Add(a.TostringO);}Console.writeLine(myList.Count); Console.writeLine(myList.Capacity);System.Collections.IEnumerator myEnumerator = myList.GetEnumerator();while(m yEnu merator.MoveNext())Console.writeC4{0}^\myEnumerator.Current);Console.ReadLine();程序运行输出为().(选择一项)int [5] {6, 9, 7, 8, 3}, newa) 19201234567891011121314151617181920b) 2010001234567891011121314151617181920c) 202001234567891011121314151617181920d) 203212345678910111213141516171819207. 在C#屮,()正确定义了一个数组。
a) int iArray = new int[l 0];b) intf] iArray = new int;c) int[] iArray = new int[10]d) int[] iArray = new int(10);& int [] [] myArray3=new int [3] [] {new int [3] (5, 6, 2}, new int [2] {3,2}}; myArray3 [2] [2]的值是()。
A. 9B. 2C. 6D. 越界9. C#中,关于Array 类和ArrayList 类,错误的是()。
a) ArrayList 类是Array 类的优化版本b) Array 类的元素个数是固定的c) Array 类的下界始终是0d) ArrayList 是单维的10. C#中,ArrayList 中()属性可以指定ArrayList 的容量。
a) Valueb) Capacityc) Totald) Count7在C#中,下列代码运行的结果是()int [] num=new int [] {1, 2, 3, 4, 5};ArrayList arr=new ArrayList();For(int i=0;i<num. Lengtn;i++){arr. add (num[ij);arr. Remove (arr [2]);Console. Writer (arr [2]);A.1B.2C.3D.419.在C#中,下列代码的运行结果是()Tnt [] num=new int[] {3, 4, 5, 3, 8};Int index=Array. IndexOf(num, 3);Console. WriteLine (index); (选择一项)a)-1b)0c) 1d) 332.在C#中,下列代码的运行结果是()Int [] num=new int[] (1, 3, 5};Array Us t arr 二new ArrayList ();For(int i=0;i<num. length;i++) {arr・ Add (num[i]);}arr. Insert (1, 4);Console. WriteLine(arr[2]);(选择一项)a) 1b) 3c) 4d) 54&在C#中,下列代码的运行结果是() Static void MainO { int[] num = new int[] {1, 2, 3, 4, 5};Array. Reverse(num);foreach (int i in num){Console. Write (i);}}A)0000;B)12345;C)54321;D)不确定1>在C#中,下列代码的运行结果是()oInt [] age = new int [] {16, 18,20,14,22};Foreach (int i age){If(i>18)continue;Console. Write(i. ToString() + " ”); }a)16 18 20 14 22;b)16 18 14 22;c)16 18 14 ;d)16 1823.在C#屮,下列代码的运行结果是()(选择一项)Class Test{Static void Show Array Info (int [] student){for (int T =0; Kstude nt .Length; i++){Console. Write (student [i]++);Console. Write(“);}}Static void MainO{int [] student = new int [] {1, 2, 3, 4, 5}; ShowArraylnfo (student);Console. Write( );ShowArraylnfo (student);a. 1 2 3 4 5b.c.b. 2 3 4 5 63 4 5 6 734.在c#中,下列代码的运行结果是0 Hashtable hsStu = new Hashtable(); hsStu. Add(3, ” 甲”);hsStu. Add (2, ”乙”);hsStu. Add (1, ”丙”);Console. WriteLine(hsStu[3]);a. 3b.甲c. 1d.丙8.在c#中,下列代码运行结果是()Int [] names二new int [] {4, 3, 2, 1}Array. Sort (names, 1, 3)Foreache(int name in names){Consol e. Write (name);}A.4321B.1234C.4123D.312411.在C#中,()正确定义了一个数组。
A.int iArray二new int [10];B.int[] iArray=new int;C.int[] iArray=new int[10];D.int[] iArray=new int (10);22)在C#中,下列代码的运行结果是()。