小编and*_*odd的帖子

JSON反序列化器返回NULL值

我试图通过C#控制台应用程序使用REST API,并且我已经获得了web服务以返回JSON文件,其格式为:

{"status":200,"result":{"postcode":"SW1W0DT","quality":1,"eastings":528813,"northings":178953,"country":"England","nhs_ha":"London","longitude":-0.145828,"latitude":51.494853,"european_electoral_region":"London","primary_care_trust":"Westminster","region":"London","lsoa":"Westminster 023E","msoa":"Westminster 023","incode":"0DT","outcode":"SW1W","parliamentary_constituency":"Cities of London and Westminster","admin_district":"Westminster","parish":"Westminster, unparished area","admin_county":null,"admin_ward":"Warwick","ccg":"NHS Central London (Westminster)","nuts":"Westminster","codes":{"admin_district":"E09000033","admin_county":"E99999999","admin_ward":"E05000647","parish":"E43000236","parliamentary_constituency":"E14000639","ccg":"E38000031","nuts":"UKI32"}}}
Run Code Online (Sandbox Code Playgroud)

我创建了一个类AddressInfo如下:

public class AddressInfo {
    public string postcode { get; set; }
    public int quality { get; set; }
    public int eastings { get; set; }
    public int northings { get; set; }
    public string country { get; set; }
    public string nhs_ha { get; set; }
    public string admin_county { get; set; }
    public string admin_district { get; set; }
    public string admin_ward …
Run Code Online (Sandbox Code Playgroud)

c# json

1
推荐指数
1
解决办法
272
查看次数

将VB转换为C#(数组)

我目前对VB.net不是很熟悉,并且在将以下代码转换为C#时遇到了一些麻烦.

Dim itemList As New ArrayList
Dim strMyitemList(itemList.Count - 1) As String

        For x = 0 To (itemList.Count - 1)
            strMyitemList(x) = itemList(x)
        Next
Run Code Online (Sandbox Code Playgroud)

到目前为止我有:

ArrayList itemList = new ArrayList();
string[] strMyitemList = new string[itemList.Count -1];

            for (int x = 0; x <= (itemList.Count - 1); x++)
            {
                strMyitemList[x] = itemList(x);
            }
Run Code Online (Sandbox Code Playgroud)

我在"itemList(x)"上收到错误CS0149"Method name expected".

谢谢

c# vb.net arrays

0
推荐指数
1
解决办法
69
查看次数

标签 统计

c# ×2

arrays ×1

json ×1

vb.net ×1