private int[] _money_val = {1, 10, 100, 1000, 10000};
private int[] _money_num = {0, 0, 0, 0, 0};
public int this[int m_value]
for(int m = 0; m < _money_val.Length; m++)
if(_money_val[m] == m_value)
int money_sum = _money_val[m]*_money_num[m];
Console.WriteLine("... get(): this[{0}]=={1}", m_value, money_sum);
return _money_val[m]*_money_num[m];
Console.WriteLine("... get(): this[{0}]==0!((", m_value);
for(int m = 0; m < _money_val.Length; m++)
if(_money_val[m] == m_value)
Console.WriteLine("... set(): до установки: this[{0}]=={1}", m_value, _money_num[m]);
Console.WriteLine("... set(): после установки: this[{0}]=={1}", m_value, _money_num[m]);
Console.WriteLine("... set(): значение {0} не устанавливалось, т.к. не распознано!((", value);
public bool this[int m_value, int m_sum]
int sum_value = this[m_value];
Console.WriteLine("... get(): this[{0},{1}]=={2}", m_value, m_sum, sum_value);
return sum_value >= m_sum ? true : false;
public static void Main(string[] args)
MoneyBox mbox = new MoneyBox();
for(int i = 0; i < 10; i++)
int val = (int)Math.Pow((double)10, (double)i);
Console.WriteLine("Num = {0}, money count = {1}", num, count);
for(int i = 1; i < 10000; i*=10)
bool exist = mbox[i, 4*i];
string str = exist ? "есть в копилке!)" : "нет в копилке!(";
Console.WriteLine("{0} денег номиналом {1} {2}", 4*i, i, str);