首页 > 解决方案 > 从某个 page.cs 获取并返回一个动态量到类

问题描述

public class Paypal//name of class
public string Pay { get; set; }//Field called pay
public Paypal() { }//General constructor
public class Amount//into Paypal class
{
    [JsonProperty(PropertyName = "currency_code")]
    public string CurrencyCode { get; set; }

    [JsonProperty(PropertyName = "value")]
    public string Value { get; set; }
}

现在是 Paypal 类的一个方法:

public static string ConvertToPay()
{
    var request = new OrdersRequest
    {
        Intent = "CAPTURE",
        PurchaseUnits = new PurchaseUnit[]{ new PurchaseUnit{
        Amount = new Amount//New object from above
                {
                    CurrencyCode = "USD",
                    Value ="???"//Here I want to get a different amount every time
                }
            }
        }
    };

    var jsonContent = JsonConvert.SerializeObject(request);
    return jsonContent;
}

在页面 some.cs 中写

Paypal.Amount payamo = new Paypal.Amount();
payamo.Value= SumOfClass.Items[SumOfClass.SelectedIndex].Value;

这没用!价值如何获得可变金额?我尝试了几种方法,都没有成功

标签: asp.nethttpclient

解决方案


推荐阅读