无法将类型'decimal'隐式转换为'decimal []' [英] Cannot implicitly convert type 'decimal' to 'decimal[]'

查看:112
本文介绍了无法将类型'decimal'隐式转换为'decimal []'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我是dis平台的新用户.你能帮我吗,我有


I m new user in dis platform. can u help me, i have

rctPayment

billPayment

我想减去,结果存储在数组类型的十进制变量中,所以我使用此代码,所以得到了这个错误
不能将类型"decimal"隐式转换为"decimal []" ,所以请帮助我........

i want to subtract and the result is store in a decimal varibles with array type so i using this code so i got this error
Cannot implicitly convert type ''decimal'' to ''decimal[]'' so please help me........

private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection("Data Source=localhost;User ID=test;Initial Catalog=SQL;password=sa;");
            SqlCommand cmd = new SqlCommand("select RctDate,RctNo,CustomerCode,Amt from FocusReceipts;Select * from(Select date,invoice,customerCode,customer,gross,salesmancode,salesmanName,0 as Status from FocusInvoiceForSC union all Select  date,invoice,customerCode,customer,gross,salesmancode,salesmanName,0 as Status from CustomersOpening)BillingDetail order by date;Select distinct CustomerCode from FocusReceipts", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);

            string billNo = string.Empty;

            for (int counter = 0; counter < ds.Tables[2].Rows.Count; counter++)
            {
                String customerCode=ds.Tables[2].Rows[counter]["CustomerCode"].ToString();

                DataRow []drPayment = ds.Tables[0].Select("CustomerCode=''" + customerCode +"''");
                for (int rctCounter = 0; rctCounter < drPayment.Length; rctCounter++)
                {
                    decimal rctPayment= decimal.Parse(drPayment[rctCounter]["Amt"].ToString());
                    DataRow[] drBills = ds.Tables[1].Select("CustomerCode=''" + customerCode + "'' and invoice not in (''" + billNo + "'')");

                    for (int billCounter = 0; billCounter < drBills.Length; billCounter++)
                    {
                        decimal billPayment = decimal.Parse(drBills[billCounter]["Gross"].ToString());

                       // decimal Adjustpayment = rctPayment - billPayment;
                        decimal[] AdjustPayment =rctPayment-billPayment;
                        for (int i = 0; i <  AdjustPayment.Length; i++)
                        {
                            decimal Adjustment =decimal.Parse( AdjustPayment[i].ToString());
                        }
                       
                      
                      



                        billNo = "''" + drBills[billCounter]["Invoice"].ToString() + "'',";
                    }
                    if (billNo.Length > 0) { billNo = billNo.Substring(0, billNo.Length - 1); }
                } 
            }
        }

推荐答案

decimal[] AdjustPayment =rctPayment-billPayment;


您需要执行类似
的操作


You need to do something like

decimal[] AdjustPayment = new decimal[]{rctPayment-billPayment}; 


感谢Abhinav ji,
您能解决我的问题吗,在给定的代码中有4个字段Customercode,rctPayment,billPayment和AdjustPayment,我想将已创建的记录添加到另一个表中,所以请....
Thanks Abhinav ji,
Can u solve my problem, in the giving code there are 4 field Customercode,rctPayment,billPayment and AdjustPayment, i want the founded record add in the another table, So please.......


这篇关于无法将类型'decimal'隐式转换为'decimal []'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆