Languages
[Edit]
EN

C#/.NET - random bytes

2 points
Created by:
JustMike
3515

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
Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.