Php 2d array as C# 2d array/struct
- by ile
I'm using MailChimp's API to subscribe email to a list. Function listsubscribe() is used for email subscription:
public static listSubscribe(string apikey, string id, string email_address, array merge_vars, string email_type, boolean double_optin, boolean update_existing, boolean replace_interests, boolean send_welcome)
I downloaded MailChimp's official .NET wrapper for their API
When looking in Visual Studio, this is one of overloaded functions:
listSubscribe(string apikey, string id, string email_address, MCMergeVar[] merges)
When I click on definition of MCMergeVar[], this comes out:
[XmlRpcMissingMapping(MappingAction.Ignore)]
public struct MCMergeVar
{
public string name;
public bool req;
[XmlRpcMissingMapping(MappingAction.Error)]
public string tag;
public string val;
}
In a php example on MailChimp's website, this is how merges variable is declared:
$merge_vars = array('FNAME'=>'Test', 'LNAME'=>'Account', 'INTERESTS'=>'');
How to write this array correctly for my C# wrapper?
I tried something like this:
MCMergeVar[] subMergeVars = new MCMergeVar[1];
subMergeVars["FNAME"] = "Test User";
But it requires an int in place where "FNAME" is now placed, so this doesn't work...
Thanks in advance,
Ile