如何将PHP代码中的嵌套数组转换为c#
这段php代码的c#等价物是什么? 我很困惑,因为数组成员将被动态提供如何将PHP代码中的嵌套数组转换为c#,c#,php,json,C#,Php,Json,这段php代码的c#等价物是什么? 我很困惑,因为数组成员将被动态提供 ?php $messages = array( 'sender' => "SampleName", 'messages' => array( array( 'number' => 918123456789, 'text' => rawurlencode('This is your message')
?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')
)
)
);
以下是你所期望的吗
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; }
}
公共类消息
{
公共字符串发送方{get;set;}
公共列表消息{get;set;}
}
公共类ArrayObject
{
公共整数{get;set;}
公共字符串文本{get;set;}
}
如果键名不是动态的,则使用匿名类型,否则使用字典。number
应该是long
,因为OP number大于int.Max