ok guys what im trying here is to fill array with a big integer number(which is string) by using class-objects
first i made two references n1\n2 to the objects entry and arr
-constructor to assign entry to null
i used a property ( as wanted in the question ) to fill them
then i used the pad left to make them from equal length
then i made another constructor to fill the array but its makin an error
the error is not in the compile time but in the run-time :S
can anyone figure out wats going on
namespace Program
{
class BigIntegerNumber
{
public string entry;
int[] arr;
public BigIntegerNumber()
{
entry = null;
}
public string Fill
{
get
{
return entry;
}
set
{
entry = value;
}
}
public BigIntegerNumber(int s)
{
arr = new int[s.Length];
for(int i=0;i<s;i++)
arr[i] = Convert.ToInt32(entry[i] - 48);
}
static void Main(string[] args)
{
BigIntegerNumber n1 = new BigIntegerNumber();
BigIntegerNumber n2 = new BigIntegerNumber();
Console.Write("Please,Enter the first number :");
n1.Fill = Console.ReadLine();
Console.Write("Please,Enter the second number :");
n2.Fill = Console.ReadLine();
int local_size;
if (n1.entry.Length > n2.entry.Length)
{
n2.entry = n2.entry.PadLeft(n1.entry.Length, '0');
local_size = n1.entry.Length;
}
else
{
n1.entry = n1.entry.PadLeft(n2.entry.Length, '0');
local_size = n2.entry.Length;
}
Console.WriteLine(n1.entry);
int s1 = n1.entry.Length;
Console.WriteLine(n2.entry);
int s2 = n2.entry.Length;
n1 = new BigIntegerNumber(s1);
n2 = new BigIntegerNumber(s2);
}
}
}