0

I am doing Python for the 1st time, but I am familiar with C#. I need to convert python to C#.

I saw this syntax that I couldn't understand. I Googled for it but couldn't find anything helpful.

Python Code:

asmt[pnric]['claim'].keys()

Content of asmt[pnric]['claim']:

{'6809255581E0035': {'ccode': ['HT'], 'cdate': 20130314, 'vdate': 20130309, 'hcode': 'SGH'}, '6809255581E0040': {'ccode': ['HT'], 'cdate': 20130912, 'vdate': 20130907, 'hcode': 'SGH'}, '6809255581E0032': {'ccode': ['HT'], 'cdate': 20130110, 'vdate': 20130104, 'hcode': 'SGH'}, '6809255581E0037': {'ccode': ['HT'], 'cdate': 20130411, 'vdate': 20130406, 'hcode': 'SGH'}, '6809255581E0039': {'ccode': ['HT'], 'cdate': 20130704, 'vdate': 20130629, 'hcode': 'SGH'}}

Content of asmt[pnric]['claim'].keys():

['6809255581E0035', '6809255581E0040', '6809255581E0032', '6809255581E0037', '6809255581E0039']

What does the keys() method do? It seems to return a list of keys in the ['claim'].

How can I convert this to C#?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
KS Kian Seng
  • 319
  • 1
  • 6
  • 14
  • its a map so `keys()` returns the `keys` for the embedded map – EdChum Jun 06 '14 at 09:29
  • 1
    If you're familiar with C#, you should be familiar with [`Dictionary.Keys`](http://stackoverflow.com/questions/1276763/how-to-get-the-list-of-key-in-dictionary-c-sharp). – user2357112 Jun 06 '14 at 09:30
  • @jonsharpe Translating simple `keys()` call to C# is trivial indeed and covered by the linked answer. However if you take a look at the values of `asmt[pnric]['claim']` then it's clear that conversion to C# `Dictionary` type is not straightforward (depending on the .NET Framework version) since it involves either using `dynamic` or casting to `object`. Dear OP, if you have problems with complex dictionary definition in C# and not only with `keys()` call, then edit the question to make it clear. – ElmoVanKielmo Jun 06 '14 at 09:39

0 Answers0