Languages
[Edit]
EN

C#/.NET - generate random bytes

2 points
Created by:
Marcino
390

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

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