- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
所以,我是 C# 和对象编程的新手,我遇到了一个小问题。
在基类中我有这个(它基本上将字符串转换为 double[]:
namespace PersonalSpendings
{
class Money
{
private decimal money { get; set; }
public Money(string str)
{
//conversion from string to double[]
int j = 0;
string[] str2 = str.Split(new char[] { ' ', ',', '.' },
StringSplitOptions.RemoveEmptyEntries) ;
double[] strFinal = { '0', '0', '0' };
foreach(string i in str2)
{
strFinal[j] = double.Parse(i);
j++;
}
j--;
}
}
}
我不明白为什么它不允许我创建另一个构造函数(具有不同的参数):
namespace PersonalSpendings
{
class Income: Money
{
public Income(double amount, string name)
{
}
public Income(string str) : base(str)
{
}
}
}
第一个构造函数有问题:(双倍数量,字符串名称)。
我不能创建特定于派生类的构造函数吗?
最佳答案
是的,您可以,但是由于您的基类只有一个带参数的构造函数,您需要从派生类中的任何构造函数调用它。
public Income(double amount, string name) : base(/* something */)
{
}
public Income(string str) : base(str)
{
}
关于c# - 没有给定的参数对应于 'sir'的所需形式参数 'Money.Money(string)',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55557503/
我将 Money/Money 与 Symfony 和 doctrine 一起使用,但我不确定应该如何执行映射。目前我使用以下内容,导致此错误消息; 错误: Money\Money could not
我指的是 moneyphp/money我计划在我们处理货币的项目之一中使用它。文档很棒,只是它没有涉及如何在数据库中持久化。它谈到将货币对象编码为 JSON,但存储字符串使得很难像比较金额或货币那样简
所以,我是 C# 和对象编程的新手,我遇到了一个小问题。 在基类中我有这个(它基本上将字符串转换为 double[]: namespace PersonalSpendings { class
我正在使用 RubyMoney/money-rails gem,我对它非常满意。 现在我需要为 money 列添加更多精度,所以我定义了一种新货币 :subunit => "S
为什么是assertNotEquals(new Money(4.0), new Money(4.0));相等吗? 此测试失败。 我真的不明白为什么这个断言不成功。 是因为assertNotEquals
如何使用 php 将这个数字 247936 转换为这个 $2,479.36? 我尝试了几种选择,例如: setlocale(LC_MONETARY, 'en_US'); echo money_form
我有一个具有数据类型 joda.money 属性的类。如何将此属性映射到 mysql 中。 我的类(class)是: @Table(name="products") public class Prod
我有一个具有数据类型 joda.money 属性的类。如何将此属性映射到 mysql。 我的类(class)是: @Table(name="products") public class Produc
我坚持使用加/减方法来定义一个名为 Money 的类,该类的对象代表美元的金额。该类应该有 2 个 int 类型的实例变量,分别表示美元和美分的金额。包括一个具有 2 个 int 类型参数(表示美元和
我有一个问题,已尝试通过 Google 搜索但尚未找到答案。我想做的是使用存储过程在 MySQL 中的两个帐户之间转账。例如,如果我使用调用转移 (20,'Test',3,5)。然后我会从 accou
我想使用应用内结算来实现虚拟货币:例如,用户可以购买 50、100 和 250 个硬币的集合。 我想知道如何管理每个用户拥有的硬币数量。我必须自己管理还是 Android 是否为此提供了一些东西?如果
以下是“pc”表,其中包含有关 pc 的详细信息。 user=> SELECT * FROM pc; code | model | speed | ram | hd | cd | p
我正在通过 codeacademy 学习 Python,并且陷入了这个 lesson : 我的代码是: def hotel_cost(nights): return 140 * nights
我有一个小型财务应用程序,前端是 PHP,后端是 MySQL。我有古老的偏见,我在 MySQL 中将货币值存储为整数美分。我的 HTML 表单允许输入美元值,例如“156.64”,我使用 PHP 将其
我正在尝试获取特定日期欧元和美元之间的汇率。问题是我总是得到日期的交换敢:LocalDate{year=2016, month=1, dayOfMonth=8} 如果我在查询中指定日期并不重要。 这是
如何创建一个仅以货币格式格式化输入的 edittext 条目?当用户输入 5 时,我希望输入看起来像“$0.05”,然后当他们输入 3 时,输入现在应该像“$0.53”,最后他们输入 6,输入应该像“
说明如下: money保存货币值数据类型,范围为-922337203685477.5808到+922337203685477.5808最大长度为8字节。 smallmoney保存货币值数据类型,
我已经将 django-money 模块安装到一个项目中。当尝试在模板中呈现时,将呈现货币文件: $100.00 有什么方法可以只渲染没有符号的十进制值吗?如: 100.00 最佳答案 money
pom.xml 中添加的依赖: javax.money money-api 1.0.3 相关代码: MonetaryAmount mon = Monetary.getDef
我有这个用于接受金钱的文本框的自定义验证: //custom validator for money fields $.validator.addMethod("money", function (v
我是一名优秀的程序员,十分优秀!