T
T
Timofey2020-03-07 06:58:39
.NET
Timofey, 2020-03-07 06:58:39

How to write a function that, for a sorted array of integers, determines whether it contains a given value?

https://ideone.com/432iJ3 I tried in many ways, but since I have been doing c# for 4 days, I don’t have the proper knowledge ....

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
breathtaking, 2020-03-07
@timofeygusevopal

Linq has a Contains() function

var array = new int[] { 0, 1, 2, 3, 4, 5 };
Console.WriteLine(array.Contains(3) ? "Contains" : "Not contains");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question