Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi..
I'm beginner Programmer,
when I want to make simple program, I got some Error.

C#
        string strDiurai = null;
        string Tbl1 = null;
        string [] arrBelasan = {"SEPULUH ",
    "SEBELAS ",
    "DUA BELAS ",
    "TIGA BELAS ",
    "EMPAT BELAS ",
    "LIMA BELAS ",
    "ENAM BELAS ",
    "TUJUH BELAS ",
    "DELAPAN BELAS ",
    "SEMBILAN BELAS "
};
    Tbl1 = arrBelasan(Convert.ToInt32(strDiurai)); <-- Error


The error say "method, delegate or event is expected".
what Should I do?

Sorry my english not good. :)
Posted
Comments
Rahul Rajat Singh 19-Jun-13 1:26am    
This code snippet seems Ok to me. Perhaps the class of function containing the code has some problem. Could you show the the full code so that the problem can be analysed.
IshaqSalam 19-Jun-13 1:27am    
class Class2
{
public string Terbilang(Double angka)
{
string strAngka = null;
string strDiurai = null;
string Urai = null;
string Tbl1 = null;
string Tbl2 = null;
short x = 0;
short y = 0;
short z = 0;
string [] arrBelasan = {"SEPULUH ",
"SEBELAS ",
"DUA BELAS ",
"TIGA BELAS ",
"EMPAT BELAS ",
"LIMA BELAS ",
"ENAM BELAS ",
"TUJUH BELAS ",
"DELAPAN BELAS ",
"SEMBILAN BELAS "
};
dynamic [] arrSatuan = {
"DUA ",
"TIGA ",
"EMPAT ",
"LIMA ",
"ENAM ",
"TUJUH ",
"DELAPAN ",
"SEMBILAN "
};
angka = Math.Round(angka);
strAngka = (angka.ToString()).Trim();
while (x < strAngka.Length)
{
x += 1;
strDiurai = strAngka.Substring( x, 1);
y += short.Parse(strDiurai);
z = (short)((strAngka.Length) - x + 1);
if (short.Parse(strDiurai) == 1)
{
if ((z == 1 | z == 7 | z == 10 | z == 13))
{
Tbl1 = "SATU ";
}
else if ((z == 4))
{
if ((x == 1))
{
Tbl1 = "SE";
}
else
{
Tbl1 = "SATU ";
}
}
else if ((z == 2 | z == 5 | z == 8 | z == 11 | z == 14))
{
x += 1;
z = (short)((strAngka.Length) - x + 1);
Tbl2 = "";
Tbl1 = arrBelasan(Convert.ToInt32(strDiurai)); //<-- Error
}
else
{
Tbl1 = "SE";
}
}
else if (int.Parse(strDiurai) > 1 & int.Parse(strDiurai) < 10)
{
Tbl1 = arrSatuan(Int32.Parse(strDiurai) - 2 ); //<-- Error
}
else
{
Tbl1 = "";
}
if (int.Parse(strDiurai) > 0)
{
if ((z == 2 | z == 5 | z == 8 | z == 11 | z == 14))
{
Tbl2 = "PULUH ";
}
else if ((z == 3 | z == 6 | z == 9 | z == 12 | z == 15))
{
Tbl2 = "RATUS ";
}
else
{
Tbl2 = "";
}
}
else
{
Tbl2 = "";
}
if ((y > 0))
{
switch (z)
{
case 4:
Tbl2 += "RIBU ";
y = 0;
break;
case 7:
Tbl2 += "JUTA ";
y = 0;
break;
case 10:
Tbl2 += "MILYAR ";
y = 0;
break;
case 13:
Tbl2 += "TRILYUN ";
y = 0;
break;
}
}
Urai = Urai + Tbl1 + Tbl2;
}
return Urai + "RUPIAH";
}
lukeer 19-Jun-13 2:02am    
The usual way to provide such information in this forum is to
- use the "Improve question" link,
- put the code in the original question and
- wrap it in "pre" tags: <pre lang="c#">YourCodeHere();</pre>
That way code becomes much more readable.
lukeer 19-Jun-13 1:59am    
Actually, no. Indexed access to an array item is done in square brackets, not parentheses.

Here you need to use square braces for accessing array element instead of parentheses
Tbl1 = arrBelasan[Convert.ToInt32(strDiurai)];
 
Share this answer
 
v2
Thanks you very much..

you are the Master C# :) :)
 
Share this answer
 
how to call class?

C#
private void btnterbilang_Click(object sender, EventArgs e)
        {
            //LHasil.Text=
            LHasil.Text = Terbilang(double.Parse(txtinput.Text)); <--ERROR
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900