You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 07:00:57