Review my solution it might has hidden error but it works fine....
namespace AllocationInClass
{
public partial class Form1 : Form
{
public class Bill
{
private const int MAX_CHAR_ARRAY_LENGTH=32;
private const int SIZE_OF_CHAR = 1;
private const int SIZE_OF_INT = 4;
public const int SIZE_OF_ALL_MEMBERS = SIZE_OF_INT +
3 * 4 * 5* SIZE_OF_CHAR * MAX_CHAR_ARRAY_LENGTH +
124;
private int recordId;
private string[][][] billname=new string[3][][];
public Bill()
{
int k1,k2,k3;
for (k1 = 0; k1 < 3; k1++)
{
billname[k1] = new string[4][];
for (k2 = 0; k2 < 4; k2++)
{
billname[k1][k2] = new string[5];
for (k3 = 0; k3 < 5; k3++)
{
billname[k1][k2][k3] = "";
}
}
}
}
public Bill(int XrecordId, string[][][] Xbillname)
{
RECORDID = XrecordId;
BILLNAME = Xbillname;
}
public int RECORDID
{
get { return recordId; }
set { recordId = value; }
}
public string[][][] BILLNAME
{
get { return billname; }
set
{
int k1, k2, k3;
int[][][] stringSize = new int[3][][];
string[][][] billnameString = new string[3][][];
for (k1 = 0; k1 < 3; k1++)
{
stringSize[k1] = new int[4][];
billnameString[k1] = new string[4][];
for (k2 = 0; k2 < 4; k2++)
{
stringSize[k1][k2] = new int[5];
billnameString[k1][k2] = new string[5];
for (k3 = 0; k3 < 5; k3++)
{
stringSize[k1][k2][k3] = value[k1][k2][k3].Length;
billnameString[k1][k2][k3] = value[k1][k2][k3];
if (MAX_CHAR_ARRAY_LENGTH >= stringSize[k1][k2][k3])
{
billnameString[k1][k2][k3] = value[k1][k2][k3] + new string(' ', MAX_CHAR_ARRAY_LENGTH - stringSize[k1][k2][k3]);
}
else
{
billnameString[k1][k2][k3] = value[k1][k2][k3].Substring(0, MAX_CHAR_ARRAY_LENGTH);
}
billname[k1][k2][k3] = billnameString[k1][k2][k3];
}
}
}
}
}
}
Bill[] bly = new Bill[2];
public Form1()
{
InitializeComponent();
}
private void FormLoad(object sender, EventArgs e)
{
int i,j,k1,k2,k3;
MessageBox.Show(Bill.SIZE_OF_ALL_MEMBERS.ToString(), "SIZE_OF_ALL_MEMBERS");
for (i = 0; i < 2; i++)
{
bly[i] = new Bill();
bly[i].RECORDID = i;
for (k1 = 0; k1 < 3; k1++)
{
for (k2 = 0; k2 < 4; k2++)
{
for (k3 = 0; k3 < 5; k3++)
{
bly[i].BILLNAME[k1][k2][k3] = "Hello " + k1.ToString() + "," + k2.ToString() + "," + k3.ToString();
MessageBox.Show(bly[i].BILLNAME[k1][k2][k3],
"bly[" + i.ToString() + "].BILLNAME[" + k1.ToString() + "]" + "[" + k2.ToString() + "]" + "[" + k3.ToString() + "]");
}
}
}
}
}
}
}