CKTIS / C#
System.Random: referência prática
System.Random: referência prática: Random gera uma sequência pseudoaleatória determinística dependente do estado e do seed.
Versão: .NET API; verified against .NET 10 reference surface
Sintaxe
System.Random /* select a documented member or constructor */Random gera uma sequência pseudoaleatória determinística dependente do estado e do seed.
Usa-o para simulações e sorteios não criptográficos; partilha Random.Shared.
Não serve para segredos e o mesmo seed reproduz a sequência.
O limite superior de Next é exclusivo e um intervalo vazio devolve o limite inferior.
O programa completo usa realmente System.Random; o stdout exato esperado é 9.
Exemplos
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
var random = new Random(123);
Console.WriteLine(random.Next(10));
Resultado
9
O programa completo usa realmente `System.Random`; o stdout exato esperado é `9`.