KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm busy preparing for the MCTS 70-536 exam, according to the exam book (Microsoft Press - .NET Framework - Application Development Foundation Self Paced Training Kit 2nd Edition), this code sample: ArrayList al = new ArrayList(); al.AddRange(new string[] { "Hello", "world", "this", "is", "a", "test" }); Console.WriteLine(al.BinarySearch("this")); Outputs the value '2' to the console because the item 'this' is at index 2. Agreed that is the output I get when I run that code. However if I run Console.WriteLine(al.BinarySearch("world")); I would expect to get the value 1 in the console since 'world' would be at index 1, however I get the value -7 ? Could anyone please explain how this works? Thanks
Tags (comma-separated)
Save Edits
Cancel