Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created April 5, 2019 01:23
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/6419fb97d8507bd26a39f7b071137f97 to your computer and use it in GitHub Desktop.
Save parzibyte/6419fb97d8507bd26a39f7b071137f97 to your computer and use it in GitHub Desktop.
/*
Demostración de la generación de
números aleatorios en C#
usando Random
@author parzibyte
*/
using System;
class MainClass {
public static void Main (string[] args) {
Random random = new Random();
// Recuerda que el segundo argumento es el límite
// superior exclusivo
// Entre 1 y 10
int numero = random.Next(1, 11);
Console.WriteLine(numero);
// Entre 1 y 2
numero = random.Next(1, 3);
Console.WriteLine(numero);
// Entre 50 y 200
numero = random.Next(50, 201);
Console.WriteLine(numero);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment