Languages
[Edit]
EN

C#/.NET - generate random bytes

2 points
Created by:
Marcino
720

Random bytes example

public static class RandomUtils
{
	public static string generateBytes(int count)
	{
		Random random = new Random();
		byte[] result = new byte[count];

		random.NextBytes(result);

		return result;
	}
}

Example:

string bytes = RandomUtils.generateBytes(6);

foreach(byte entry in bytes)
	Console.Write(entry + " ");

Console.WriteLine();

Output:

34 4 1 197 85 145
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

C# / .NET - random

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join