Array.Contains
Skip to content
mnscript
bool Array.Contains(any[], any) 

Description ​

Returns whether an item in an array

Arguments ​

any[] - The array to check for the item's existence in
any - The item to search for

Returns ​

bool - True if the array contains the item, false if it does not

Example ​

msc
// Predefines
using Console;
using Array;

// EXAMPLE 1 - Illustration of Array.Length
string[] sentence = new string[5];

sentence[1] = "Sometimes";
sentence[2] = "I";
sentence[3] = "dream";
sentence[4] = "about";
sentence[5] = "cheese"; // CHEEEEEEEESE

//See if array contains the string "cheese"

if(Array.Contains(sentence, "cheese")){
    Console.WriteLine("Array contains 'cheese'");   
} else {
    Console.WriteLine("Array doesn't contains 'cheese'"); 
}