简体   繁体   中英

How do I convert this nested arrays in PHP Code to c#

What would be the c# equivalen of this php code? I am confused as the the array members would be dynamically supplied?

?php
 
$messages = array(
    'sender' => "SampleName",
    'messages' => array(
        array(
            'number' => 918123456789,
            'text' => rawurlencode('This is your message')
        ),
        array(
            'number' => 918987654321,
            'text' => rawurlencode('This is another message')
        )
    )
);

Would the below be what you expect?

public class Messages
{
   public string sender { get; set; }
   public List<ArrayObject> messages { get; set; }
}

public class ArrayObject
{
   public int number { get; set; }
   public string text { get; set; }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM