请问将php键值数组写成c#键值数组表示怎样实现,php代码如下:

CEJ-盐井 2012-11-20 10:07:36
<?php
$entries = array(
'EAVESDROP' => array(
'part' => 'v.i.',
'definition' => 'Secretly to overhear a catalogue of the crimes and vices of another or yourself.',
'quote' => array(
'A lady with one of her ears applied',
'To an open keyhole heard, inside,',
'Two female gossips in converse free —',
'The subject engaging them was she.',
'"I think," said one, "and my husband thinks',
'That she\'s a prying, inquisitive minx!"',
'As soon as no more of it she could hear',
'The lady, indignant, removed her ear.',
'"I will not stay," she said, with a pout,',
'"To hear my character lied about!"',
),
'author' => 'Gopete Sherany',
),
'EDIBLE' => array(
'part' => 'adj.',
'definition' => 'Good to eat, and wholesome to digest, as a worm to a toad, a toad to a snake, a snake to a pig, a pig to a man, and a man to a worm.',
),
'EDUCATION' => array(
'part' => 'n.',
'definition' => 'That which discloses to the wise and disguises from the foolish their lack of understanding.',
),
'ELOQUENCE' => array(
'part' => 'n.',
'definition' => 'The art of orally persuading fools that white is the color that it appears to be. It includes the gift of making any color appear white.',
),
'ELYSIUM' => array(
'part' => 'n.',
'definition' => 'An imaginary delightful country which the ancients foolishly believed to be inhabited by the spirits of the good. This ridiculous and mischievous fable was swept off the face of the earth by the early Christians — may their souls be happy in Heaven!',
),
'EMANCIPATION' => array(
'part' => 'n.',
'definition' => 'A bondman\'s change from the tyranny of another to the despotism of himself.',
'quote' => array(
'He was a slave: at word he went and came;',
'His iron collar cut him to the bone.',
'Then Liberty erased his owner\'s name,',
'Tightened the rivets and inscribed his own.',
),
'author' => 'G.J.',
),
'EMOTION' => array(
'part' => 'n.',
'definition' => 'A prostrating disease caused by a determination of the heart to the head. It is sometimes accompanied by a copious discharge of hydrated chloride of sodium from the eyes.',
),
'ENVELOPE' => array(
'part' => 'n.',
'definition' => 'The coffin of a document; the scabbard of a bill; the husk of a remittance; the bed-gown of a love-letter.',
),
'ENVY' => array(
'part' => 'n.',
'definition' => 'Emulation adapted to the meanest capacity.',
),
'EPITAPH' => array(
'part' => 'n.',
'definition' => 'An inscription on a tomb, showing that virtues acquired by death have a retroactive effect. Following is a touching example:',
'quote' => array(
'Here lie the bones of Parson Platt,',
'Wise, pious, humble and all that,',
'Who showed us life as all should live it;',
'Let that be said — and God forgive it!',
),
),
'EVANGELIST' => array(
'part' => 'n.',
'definition' => 'A bearer of good tidings, particularly (in a religious sense) such as assure us of our own salvation and the damnation of our neighbors.',
),
);
...全文
302 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
CEJ-盐井 2012-11-22
  • 打赏
  • 举报
回复
自己研究出来的,供大家参考: Dictionary<string, object> dict = new Dictionary<string, object>(); dict.Add("EAVESDROP", new object[] { new Dictionary<string, object> { {"part", "v.i."}, {"definition","Secretly to overhear a catalogue of the crimes and vices of another or yourself."}, {"quote",new string[]{ "A lady with one of her ears applied", "To an open keyhole heard, inside,", "Two female gossips in converse free —", "The subject engaging them was she.", "I think,\" said one, \"and my husband thinks", "hat she\'s a prying, inquisitive minx!\"", "As soon as no more of it she could hear", "The lady, indignant, removed her ear.", "\"I will not stay,\" she said, with a pout,", "\"To hear my character lied about!\"", "He was a slave: at word he went and came;", "His iron collar cut him to the bone.", "Then Liberty erased his owner\'s name,", "Tightened the rivets and inscribed his own.", "Here lie the bones of Parson Platt,", "Wise, pious, humble and all that,", "Who showed us life as all should live it;", "Let that be said — and God forgive it!" } }, {"author","Gopete Sherany"} } });
CEJ-盐井 2012-11-20
  • 打赏
  • 举报
回复
但我不知道使用Hashtable或Dictionary这两个类怎么实现,因为在数组里面有嵌套,而且维数不一样
全栈极简 2012-11-20
  • 打赏
  • 举报
回复
C#中可以使用Hashtable或Dictionary这两个类来实现key-value对的存储。
CEJ-盐井 2012-11-20
  • 打赏
  • 举报
回复
能否给出个实例

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧