CKTIS / C#
System.Random: riferimento pratico
System.Random: riferimento pratico: Random genera una sequenza pseudocasuale deterministica dipendente dallo stato e dal seed.
Versione: .NET API; verified against .NET 10 reference surface
Sintassi
System.Random /* select a documented member or constructor */Random genera una sequenza pseudocasuale deterministica dipendente dallo stato e dal seed.
Usalo per simulazioni ed estrazioni non crittografiche; condividi Random.Shared.
Non è adatto ai segreti e lo stesso seed riproduce la sequenza.
Il limite superiore di Next è esclusivo e un intervallo vuoto restituisce il limite inferiore.
Il programma completo usa realmente System.Random; lo stdout esatto atteso è 9.
Esempi
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));
Risultato
9
Il programma completo usa realmente `System.Random`; lo stdout esatto atteso è `9`.