I am trying to fill a buffer with random bytes. A buffer is defined as a list of bytes. This is what I want to keep as it is. Here is the definition:
namespace NameofProject { public partial class Form1 : Form { List<byte> buff = new List<byte>(); } }
And my first attempt
public static void RandomFillBuffer() { Random rnd = new Random(); rnd.NextBytes(buff); }
However, this gives such an error for buff: An object reference is required for a non-static field, method or property 'Form1.buff'
Then I just deleted the word โstaticโ (I'm not sure it's true) and it becomes โpublic void RandomFillBuffer ()โ, but this time I get this error for buff: Argument 1: cannot be converted from 'System.Collections. Generic.List 'in' byte [] '
I would be grateful for any help in resolving any of the two errors, if they make sense.
source share