Issue
I'm new to C# and having problems with the usage of a non standard constructor. This is a part of the interface of the library I'm using (QRCoder) after the latest update:
public class Contact
{
[Obsolete("This constructor is deprecated. Use WithCombinedAddress instead.")]
public Contact(string name, string country, string addressLine1, string addressLine2);
[Obsolete("This constructor is deprecated. Use WithStructuredAddress instead.")]
public Contact(string name, string zipCode, string city, string country, string street = null, string houseNumber = null);
public static Contact WithCombinedAddress(string name, string country, string addressLine1, string addressLine2);
public static Contact WithStructuredAddress(string name, string zipCode, string city, string country, string street = null, string houseNumber = null);
public override string ToString();
Before the update, this code used to work:
Contact contactCreditor;
string name, zipCode, city, country, street, housenr, strIban;
...
contactCreditor = new SwissQrCode.Contact (name, zipCode, city, country, street, housenr);
Now I get the error message
This constructor is deprecated. Use WithStructuredAddress instead.
How can I modify my code to use this new constructor?
Solution
The class no longer has a non deprecated constructor, instead call the static initializer.
Contact contactCreditor;
string name, zipCode, city, country, street, housenr, strIban;
...
contactCreditor = SwissQrCode.Contact.WithStructuredAddress(
name,
zipCode,
city,
country,
street,
housenr);
Answered By - Jodrell Answer Checked By - Marilyn (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.