2025-03-14 14:28:47 -04:00
# Lorem.NET
2014-08-19 16:23:08 -04:00
A .NET library for all things random!
2025-03-14 14:28:47 -04:00
## Usage
2014-08-19 16:23:08 -04:00
### Text Helpers
```csharp
2014-08-19 16:41:49 -04:00
// this will generate a string with three words:
2020-02-21 16:50:18 -05:00
string words = LoremNET.Generate.Words(3);
2014-08-19 16:41:49 -04:00
// this will generate a string with two to five words:
2020-02-21 16:50:18 -05:00
string words = LoremNET.Generate.Words(2, 5);
2014-08-19 16:41:49 -04:00
// this will generate a string with five to ten words with "uppercaseFirstLetter" set to "false" and "includePunctuation" set to "true":
2020-02-21 16:50:18 -05:00
string words = LoremNET.Generate.Words(5, 10, false, true);
2014-08-19 16:41:49 -04:00
// a sentence is the same as "Words" except that it will include punctuation by default and will include a "." at the end of a string:
2020-02-21 16:50:18 -05:00
string sentence = LoremNET.Generate.Sentence(5, 10);
2014-08-19 16:41:49 -04:00
// a paragraph is a string composed of multiple sentences; this paragraph will have five to six words per sentence, and four to ten sentences:
2020-02-21 16:50:18 -05:00
string paragraph = LoremNET.Generate.Paragraph(5, 6, 4, 10);
2014-08-19 16:41:49 -04:00
// paragraphs is an array of paragraphs; this method will have eight to nine words per sentence, four to five sentences per paragraph, and one to three paragraphs:
2020-02-21 16:50:18 -05:00
string[] paragraphs = LoremNET.Generate.Paragraphs(8, 9, 4, 5, 1, 3);
2014-08-19 16:41:49 -04:00
```
### Extras
```csharp
// this will generate a random valid email address:
2020-02-21 16:50:18 -05:00
string email = LoremNET.Generate.Email();
2014-08-19 16:41:49 -04:00
2014-10-27 18:56:40 -04:00
// this will generate a random hex number (i.e. a color)
2020-02-21 16:50:18 -05:00
string hex = LoremNET.Generate.HexNumber();
2014-10-27 18:56:40 -04:00
2014-08-19 16:46:14 -04:00
// this will generate a random DateTime object between 1/1/1950 and the current DateTime:
2020-02-21 16:50:18 -05:00
DateTime dateTime = LoremNET.Generate.DateTime();
2014-08-19 16:41:49 -04:00
2014-08-19 16:46:14 -04:00
// this will generate a random DateTime object between 1/1/1995 and 12/31/2020:
2020-02-21 16:50:18 -05:00
DateTime dateTime = LoremNET.Generate.DateTime(new DateTime(1995, 1, 1), new DateTime(2020, 12, 31))
2014-08-19 16:46:14 -04:00
2014-08-19 16:41:49 -04:00
// this will return "true" 55% of the time:
2020-02-21 16:50:18 -05:00
bool isTruth = LoremNET.Generate.Chance(55, 100);
2014-08-19 16:41:49 -04:00
// this will randomly select an item from the group:
string[] numbers = GetNumbers();
2020-02-21 16:50:18 -05:00
string number = LoremNET.Generate.Random(numbers);
2015-08-28 22:07:17 +02:00
// this will randomly select a value from the enum:
2025-03-14 14:28:47 -04:00
MyEnum value = LoremNET.Generate.Enum< MyEnum > ();
2015-08-28 22:07:17 +02:00
2014-08-19 16:41:49 -04:00
```
2020-02-21 17:05:10 -05:00
### Updating the Source
2014-08-19 16:41:49 -04:00
2020-02-21 16:50:18 -05:00
If you want to change the underlying source text, go right ahead!
2014-08-19 16:41:49 -04:00
```csharp
2020-02-21 16:50:18 -05:00
public void SomeStartupMethod()
2014-08-20 00:10:24 -04:00
{
2020-02-21 17:04:18 -05:00
LoremNET.Source.Update("Alright stop collaborate and listen ice is back with my brand new invention something grabs a hold of me tightly flow like a harpoon daily and nightly will it ever stop yo I don't know turn off the lights and I'll glow");
2025-03-14 14:28:47 -04:00
2020-02-21 17:04:18 -05:00
...
2014-08-20 00:10:24 -04:00
}
2015-08-28 22:07:17 +02:00
```