2012-03-26 66 views
-2

我需要計算貸款金額(P),期限(年)以及年百分比率的分期貸款的月付款(M)。 M =(P * i *(1 + i)n)/((1 + i)n-1)其中i =年百分比率/ 1200和n =期間* 12。視覺工作室的網絡服務。我似乎無法在Web服務中使用Math.Pow。這是我在代碼中的方法:網絡服務數學

這是我的錯誤消息:錯誤1'ProjectFive.payment.Math(double,double,double,double)'是'方法',在給定的上下文中無效C:\用戶\ parodeghero \文檔\ Visual Studio 2010的\項目\ ProjectFive \ ProjectFive \ payment.asmx.cs 27 38 ProjectFive

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Services; 

namespace ProjectFive 
{ 
[WebService(Namespace = "http://tempuri.org/")] 
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
[System.ComponentModel.ToolboxItem(false)] 

public class payment : System.Web.Services.WebService 
{ 
    [System.Web.Services.WebMethod()] 
    public double Math(double loan, double rate, double period, double payment) 
    { 

     rate = rate/100; 
     period = period * 12; 

     payment = loan*(rate/1200)*Math.Pow((1+(rate/1200)), period)/ Math.Pow((1 + (rate/1200)), period) - 1; 
     return payment;   
    } 
} 
} 
+1

什麼「我似乎無法使用」究竟意味着什麼?你得到編譯器錯誤還是什麼? – 2012-03-26 01:25:39

+0

分母不應該是'Math.Pow((1 +(rate/1200)),period - 1)'? – 2012-03-26 01:28:45

+0

公共雙數學(雙倍貸款,雙倍利率,雙倍期間,雙重付款) { 是的,它說這個代碼上面是無效的 – asguy 2012-03-26 01:29:25

回答

8

重命名你的方法,你不能把它叫做數學!

+2

謝謝!我間隔:) – asguy 2012-03-26 01:38:20

+2

@米奇:我認爲這是實際答案。 asgurl不能使用Math.Pow(),因爲這也是她的方法的名稱。 – 2012-03-26 01:38:54

+0

是的,你是對的@Mitch – asguy 2012-03-26 01:40:01