using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using KGySoft.CoreLibraries;
public static class Example
public static void Main()
Console.WriteLine(rnd.NextBoolean());
Console.WriteLine(rnd.NextDouble(Double.PositiveInfinity));
Console.WriteLine(rnd.NextString());
Console.WriteLine(rnd.NextDateTime());
Console.WriteLine(rnd.NextEnum<ConsoleColor>());
Console.WriteLine(rnd.NextObject<Person>().Dump());
Console.WriteLine(rnd.NextObject<ValueTuple<int, string>>());
Console.WriteLine(rnd.NextObject<IConvertible>());
Console.WriteLine(rnd.NextObject<MarshalByRefObject>());
Console.WriteLine(rnd.NextObject<int[]>().Dump());
Console.WriteLine(rnd.NextObject<IList<IConvertible>>().Dump());
Console.WriteLine(rnd.NextObject<Func<DateTime>>().Invoke());
Console.WriteLine(rnd.NextObject<ArrayList>(new GenerateObjectSettings
SubstitutionForObjectType = typeof(ConsoleColor)
Console.WriteLine(rnd.NextObject<object>(new GenerateObjectSettings
AllowDerivedTypesForNonSealedClasses = true
private static string Dump(this object o)
var convertible = o as IConvertible;
return convertible.ToString(CultureInfo.InvariantCulture);
var enumerable = o as IEnumerable;
return $"[{enumerable.Cast<object>().Select(Dump).Join(", ")}]";
return $"{{{o.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Select(p => $"{p.Name} = {Dump(p.GetValue(o))}").Join(", ")}}}";
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime BirthDate { get; set; }
public List<string> PhoneNumbers { get; set; }