Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created June 11, 2021 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/9039761a156d12e6c650af801c53bfbd to your computer and use it in GitHub Desktop.
Save parzibyte/9039761a156d12e6c650af801c53bfbd to your computer and use it in GitHub Desktop.
using System;
namespace App
{
class Programa
{
static void Main(string[] args)
{
int[] numeros = { 999, 28, 11, 96, 1, 2, 45, 0, 1 };
int busqueda = 855;
int indice = Array.IndexOf(numeros, busqueda);
if (indice == -1)
{
Console.WriteLine("El elemento {0} no existe", busqueda);
}
else
{
Console.WriteLine("El elemento {0} existe en la posición {1}", busqueda, indice);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment