这段代码用于.net core 6
:
WebCallResult<AddressInfo> CreateAddress(
string coin,
string walletId,
string label,
int chain = 0,
string gasPrice = default,
bool lowPriority = false,
CancellationToken cancellationToken = default(CancellationToken));
我想在.net framework 4.8
中使用它
在.net框架4.8中,我出现了以下错误:
类型为"?"的值不能用作默认参数,因为没有到类型"字符串"的标准转换
如何修复此错误?
编辑:
此行出现错误:
string gasPrice = default,
问题是,在gasPrice = default
中,您正在为字符串设置default
,在<C#7.1没有将default
定义为字符串,这样字符串的值将是?
,而不是像null
这样可接受的值。
出于特定原因(运行时版本(,您必须设置default(string)
或手动将值设置为null
。可以在此处找到对所有默认值的引用。