asp.net - 从某个 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;
这没用!价值如何获得可变金额?我尝试了几种方法,都没有成功
解决方案
推荐阅读
- java - 在 Android API 22 Java 8 中使用带有 log4j 2.7 的 maven jar 获取 java.lang.NullPointerException:尝试获取空数组的长度
- php - 我有一个非常不稳定的多站点 wordpress
- android-studio - 我在flutter中创建新应用程序,在vs代码终端中创建AppName它工作但是当我尝试flutter run时它显示这个错误消息
- go - 为什么这部分代码在另一部分之前执行?
- python - 如何从 firefox 浏览器缓存中恢复 jupyter notebook?
- python - qt设计器中查看python代码选项不存在
- r - 在 R 中使用 jsonlite 时,如何手动指定哪些被视为数组?在这种情况下 auto_unbox 不起作用
- c++ - 如何在我的 C++ 控制台游戏中添加计时器
- python - 如何使用 bs4 或 lxml 在 Python 中找到 XML 标记的文本行?
- javascript - iOS 11 JavaScript 找不到变量`globalThis`