I am trying to do a Buffer Holder for a big buffer stack.
And the classes are:
Buffer Class:
internal class Buffer<T>
{
private T[] buffer;
public Buffer(T[] buffer)
{
this.buffer = buffer;
}
public void clear()
{
Array.Clear(buffer, 0, buffer.Length);
}
public int length()
{
return buffer.Length;
}
}
DataPool Class:
internal sealed class DataPool<T> : List<Buffer<T>>
{
public DataPool() : base() {}
}
and how I create the bufferList:
public Server
{
DataPool<byte[]> bufferList;
byte[] = buffer;
public Server(...)
{
buffer = new byte[ServerConfig.MaxBufferSize];
this.bufferList = new DataPool<byte[]>();
}
}
Everything ok but i cant add buffer into bufferList like:
bufferList.Add(buffer); //This is not working, why?
How can I do it?
Thank you!
This should work:
You have to use
DataPool<byte>andBuffer<byte>since that causes the Buffer to accept a byte array, which is what you want.