Kev*_*vin 10 c# collections arraylist
我正忙着准备MCTS 70-536考试,根据考试书(Microsoft Press - .NET Framework - 应用程序开发基础自学训练套件第2版),此代码示例:
ArrayList al = new ArrayList();
al.AddRange(new string[] { "Hello", "world", "this", "is", "a", "test" });
Console.WriteLine(al.BinarySearch("this"));
Run Code Online (Sandbox Code Playgroud)
将值'2'输出到控制台,因为项'this'位于索引2.同意这是我运行该代码时得到的输出.
但是,如果我跑
Console.WriteLine(al.BinarySearch("world"));
Run Code Online (Sandbox Code Playgroud)
我希望在控制台中获得值1,因为'world'将在索引1,但是我得到值-7?
谁能解释一下这是如何工作的?
谢谢
| 归档时间: |
|
| 查看次数: |
3101 次 |
| 最近记录: |