C#中QRCoder库Contact类弃用构造函数的替代调用方法
QRCoder库Contact构造方法弃用后的修改方案
你使用的QRCoder库更新后,原有的Contact构造方法已被标记为弃用,需改用静态工厂方法创建实例。
原弃用代码
Contact contactCreditor; string name, zipCode, city, country, street, housenr, strIban; ... contactCreditor = new SwissQrCode.Contact (name, zipCode, city, country, street, housenr);
收到的错误提示
This constructor is deprecated. Use WithStructuredAddress instead.
修改后的代码
直接调用静态方法WithStructuredAddress即可,参数顺序和你之前传入的完全一致,仅需替换实例化方式:
Contact contactCreditor; string name, zipCode, city, country, street, housenr, strIban; ... contactCreditor = SwissQrCode.Contact.WithStructuredAddress(name, zipCode, city, country, street, housenr);
补充说明
- 该静态工厂方法的参数定义和你之前使用的弃用构造方法完全匹配,无需调整参数顺序或内容
- 若需创建合并地址格式的联系人实例,可使用对应静态方法
WithCombinedAddress
内容的提问来源于stack exchange,提问作者GrulliGramps
相关产品推荐
相关产品推荐

