Как объявить string фиксированного размера - C#
Формулировка задачи:
Доброго времени суток. Подскажите, пожалуйста, мне нужно чтобы в классе было поле string с фиксированным размером в 256 bytes. А также должно быть поле, принимающе значания 0, 1, 2 или 255 с размером в 1 byte. Как мне это объявить?
Решение задачи: «Как объявить string фиксированного размера»
textual
Листинг программы
public class Message
{
static uint SequenceNumber = 1; // for unique number of request
uint command; // type of command
char type; // status of request
uint seqNum; // unique number of request
char[] fileName = new char[128]; // file name
char[] srcPath = new char[128]; // source path
char[] dstPath = new char[128]; // destination path
byte[] usageData; // general data
public Message() { }
public Message(uint _command, char _type, char[] _fileName, char[] _srcPath, char[] _dstPath, byte[] data)
{
command = _command;
type = _type;
seqNum = SequenceNumber++;
fileName = _fileName;
srcPath = _srcPath;
dstPath = _dstPath;
if (data != null)
{
data.CopyTo(usageData, 0);
}
}