KayuSoft.Random
1.0.0
dotnet add package KayuSoft.Random --version 1.0.0
NuGet\Install-Package KayuSoft.Random -Version 1.0.0
<PackageReference Include="KayuSoft.Random" Version="1.0.0" />
paket add KayuSoft.Random --version 1.0.0
#r "nuget: KayuSoft.Random, 1.0.0"
// Install KayuSoft.Random as a Cake Addin #addin nuget:?package=KayuSoft.Random&version=1.0.0 // Install KayuSoft.Random as a Cake Tool #tool nuget:?package=KayuSoft.Random&version=1.0.0
RND
A random value generator package.
Bool()
Generates a random bool value.
returns: A boole value.
Example:
Console.WriteLine($"Bool(): {RND.Bool()}");
//Bool(): True
Byte()
Generates a random byte value.
returns: A byte value.
Example:
Console.WriteLine($"Byte(): {RND.Byte()}");
//Byte(): 128
Card()
Generates a random card of a standard deck.
returns: A card.
Example:
Console.WriteLine($"Card(): {RND.Card()}");
//Card(): AceOfSpades
CardNumber()
Generates a 16 digit card number.
returns: A string cardnumber.
Example:
Console.WriteLine($"Card(): {RND.Card()}");
//CardNumber(): 5139198941447630
CardNumber(string seperator)
Generates a 16 digit card number with specified seperator.
seperator Seperator between sections.
returns: A string cardnumber.
Example:
Console.WriteLine($"CardNumber(): {RND.CardNumber()}");
//CardNumber(" "): 4762 5421 2171 8341
Cards(int count)
Generates an array of random cards of a standard deck in specified count.
count: Count to pick cards.
returns: A card array.
Example:
Console.WriteLine($"Cards(4): {string.Join(", ", RND.Cards(4))}");
//Cards(4): SixOfHearts, FourOfDiamonds, EightOfHearts, JackOfHearts
Char(string chars)
Generates a random char value from specified string.
chars: A string value to pick the char.
returns: A char value.
Example:
string chars = "Hello World";
Console.WriteLine($"Char(chars): {RND.Char(chars)}");
//Char(chars): e
Console.WriteLine($"Random(): {chars.Random()}");
//Random(): r
Coin()
Generates a random coin side.
returns: A coin side.
Example:
Console.WriteLine($"Coin(): {RND.Coin()}");
//Coin(): Heads
Coins(int times)
Generates an array of random coin sides in specified times.
times: Times to flip coin.
returns: An array of coin sides.
Example:
Console.WriteLine($"Coins(3): {string.Join(", ", RND.Coins())}");
//Coins(3): Heads, Tails, Tails
Color()
Generates a random color.
returns: A color.
Example:
Color color = RND.Color();
Console.WriteLine($"Color(): (R: {color.R}, G: {color.G}, B: {color.B})");
//Color(): (R: 85, G: 238, B: 67)
ColorWithAlpha()
Generates a random color with alpha channel.
returns: A color with alpha.
Example:
Color colorWithAlpha = RND.ColorWithAlpha();
Console.WriteLine($"ColorWithAlpha(): (R: {colorWithAlpha.R}, G: {colorWithAlpha.G}, B: {colorWithAlpha.B}, A: {colorWithAlpha.A});
//ColorWithAlpha(): (R: 197, G: 58, B: 169, A: 248)
Coordinate()
Generates a random world coordinate.
returns: A coordinate.
Example:
Console.WriteLine($"Coordinate(): {RND.Coordinate()}");
//Coordinate(): lat: -33,1564491629398 long: 36,359565507788
Date()
Generates a random date (AC).
returns: A date.
Example:
Console.WriteLine($"Date(): {RND.Date()}");
//Date(): 30.08.1572 00:00:00
Date(DateTime end)
Generates a random date between 01.01.0001 and end values.
end: An end date.
returns: A date.
Example:
Console.WriteLine($"Date(2000, 1, 1): {RND.Date(new DateTime(2000, 1, 1))}");
//Date(2000, 1, 1): 8.09.1716 21:33:39
Date(DateTime start, DateTime end)
Generates a random date between start and end values.
start: A start date.
end: An end date.
returns: A date.
Example:
Console.WriteLine($"Date(1950, 1, 1, 1990, 1, 1): {RND.Date(new DateTime(1950, 1, 1), new DateTime(1990, 1, 1))}");
//Date(1950, 1, 1, 1990, 1, 1): 29.06.1982 05:24:13
DateUntilToday()
Generates a random date between today and 01.01.0001.
returns: A date.
Example:
Console.WriteLine($"DateUntilToday(): {RND.DateUntilToday()}");
//DateUntilToday(): 2.02.1218 20:40:29
DayOfWeek()
Generates a random day of week.
returns: A day of week.
Example:
Console.WriteLine($"DayOfWeek(): {RND.DayOfWeek()}");
//DayOfWeek(): Sunday
Dice()
Generates a random 6 sided dice value.
returns: An int dice value.
Example:
Console.WriteLine($"Dice(): {RND.Dice()}");
//Dice(): 1
Dices(int times)
Generates an array of random 6 sided dice values in specified times.
times: Times to roll dice.
returns: An int array of dice values.
Example:
Console.WriteLine($"Dices(2): {string.Join(", ", RND.Dices(2))}");
//Dices(2): 6, 6
Digit()
Generates a number between 0 and 9.
returns: An int number.
Example:
Console.WriteLine($"Digit(): {RND.Digit()}");
//Digit(): 7
Double()
Generates a random double value between 0.0 and 1.0.
returns: A double value.
Example:
Console.WriteLine($"Double(): {RND.Double()}");
//Double(): 0,0854182192522186
Double(double max)
Generates a random double value between 0.0 and max.
max: A double max value.
returns: A double value.
Example:
Console.WriteLine($"Double(10): {RND.Double(10)}");
//Double(10): 4,50023497198719
Double(double min, double max)
Generates a random double value between min and max.
max: A double min value.
max: A double max value.
returns: A double value.
Example:
Console.WriteLine($"Double(5, 10): {RND.Double(5, 10)}");
//Double(5, 10): 9,46624174922064
Float()
Generates a random float value between 0.0 and 1.0.
returns: A float value.
Example:
Console.WriteLine($"Float(): {RND.Float()}");
//Float(): 0,154844
Float(float max)
Generates a random float value between 0.0 and max.
max: A float max value.
returns: A float value.
Example:
Console.WriteLine($"Float(10): {RND.Float(10)}");
//Float(10): 4,138486
Float(float min, float max)
Generates a random float value between min and max.
max: A float min value.
max: A float max value.
returns: A float value.
Example:
Console.WriteLine($"Float(5, 10): {RND.Float(5, 10)}");
//Float(5, 10): 7,894455
HexColor()
Generates a random color in hex format.
returns: A string hex color.
Example:
Console.WriteLine($"HexColor(): #{RND.HexColor()}");
//HexColor(): #E5CC5D
Int()
Generates a random int value between 0 and max int value.
returns: A int value.
Example:
Console.WriteLine($"Int(): {RND.Int()}");
//Int(): 1217731667
Int(int max)
Generates a random int value between 0 and max.
max: A int max value.
returns: A int value.
Example:
Console.WriteLine($"Int(10): {RND.Int(10)}");
//Int(10): 2
Int(int min, int max)
Generates a random int value between min and max.
max: A int min value.
max: A int max value.
returns: A int value.
Example:
Console.WriteLine($"Int(5, 10): {RND.Int(5, 10)}");
//Int(5, 10): 8
IP()
Generates a random IPv4.
returns: A string IPv4.
Example:
Console.WriteLine($"IP(): {RND.IP()}");
//IP(): 92.21.145.251
Item(List<T> list)
Generates a random picked item from the list.
list: A list to pick item.
returns: A picked item.
Example:
List<string> list = new List<string>() { "item1", "item2", "item3", "item4", "item5" };
Console.WriteLine($"Item(list): {RND.Item(list)}");
//Item(list): item3
Console.WriteLine($"Random(): {list.Random()}");
//Random(): item1
Item(T[] array)
Generates a random picked item from the array.
list: An array to pick item.
returns: A picked item.
Example:
string[] array = new string[] { "array1", "array2", "array3", "array4", "array5" }
Console.WriteLine($"Item(array): {RND.Item(array)}");
//Item(array): array4
Console.WriteLine($"Random(): {array.Random()}");
//Random(): array2
Letter()
Generates a random letter of latin alphabet.
returns: A string letter.
Example:
Console.WriteLine($"Letter(): {RND.Letter()}");
//Letter(): K
MAC(bool withColons = true)
Generates a random MAC address.
withColons: Seperates sections with colons when it is true. Default value is true.
returns: A string MAC adress.
Example:
Console.WriteLine($"MAC(): {RND.MAC()}");
//MAC(): E3:BE:4B:9D:AA:20
Console.WriteLine($"MAC(false): {RND.MAC(false)}");
//MAC(false): 787B63A69E2B
Name()
Generates a random name.
returns: A string name.
Example:
Console.WriteLine($"Name(): {RND.Name()}");
//Name(): Samuel
Name(Gender gender)
Generates a random name in specified gender.
gender: Enum to specify gender.
returns: A string name in specified gender.
Example:
Console.WriteLine($"Name(Gender.Male): {RND.Name(Gender.Male)}");
//Name(Gender.Male): Billy
Console.WriteLine($"Name(Gender.Female): {RND.Name(Gender.Female)}");
//Name(Gender.Female): Diana
Password(int digits = 16)
Generates a random password.
digits: Digit count to generate. Default value is 16.
returns: A string password.
Example:
Console.WriteLine($"Password(): {RND.Password()}");
//Password(): BuweDEeLgOOS!5iQ
Console.WriteLine($"Password(8): {RND.Password(8)}");
//Password(8): XQviE&oZ
Pick(List<T> list, int count)
Generates a list of random picked items from the list.
list: A list to pick items.
count: Item count to pick from list.
returns: A list of picked items.
Example:
List<int> lst = new List<int>();
for (int i = 0; i < 49; i++) { lst.Add(i + 1); }
Console.WriteLine($"Pick(list, 6): {string.Join(", ", string.Join(", ", RND.Pick(lst, 6)))}");
//Pick(list, 6): 28, 5, 38, 32, 16, 14
Console.WriteLine($"Random(6): {string.Join(", ", string.Join(", ", lst.Random(6)))}");
//Random(6): 36, 20, 6, 34, 1, 7
Pick(T[] array, int count)
Generates an array of random picked items from the array.
array: An array to pick items.
count: Item couns to pick from array.
returns: An array of picked items.
Example:
int[] arr = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
Console.WriteLine($"Pick(array, 2): {string.Join(", ", RND.Pick(arr, 2))}");
//Pick(array, 2): 4, 9
Console.WriteLine($"Random(2): {string.Join(", ", arr.Random(2))}");
//Random(2): 5, 9
Time()
Generates a random time.
returns: A time.
Example:
Console.WriteLine($"Time(): {RND.Time()}");
//Time(): 10:36:47
UUID()
Generates a random UUID value.
returns: A string UUID.
Example:
Console.WriteLine($"UUID(): {RND.UUID()}");
//UUID(): 84993b79-69d4-4460-8550-0ac8c3a1d85d
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 197 | 3/14/2023 |