在我的web服務中,我必須傳遞複雜元素中的複雜元素列表。是否有可能發送複雜的元素在c#中的複雜元素列表?
我的第一節課是:
public List<JBCredential> JBCredentials{ get; set; }
public string codes { get; set; }
public string db { get; set; }
public string locale { get; set; }
public string location { get; set; }
public string mode { get; set; }
public string postcode { get; set; }
在上面的類我已經派另一個類,如下列表:
public string code { get; set; }
public string Username { get; set; }
public string Password { get; set; }
現在我想上面的類發送到我的方法。 但是,當我加入第二類列出一流的,我發現了以下錯誤
Object reference not set to an instance of an object.
請幫我解決這個問題。
我已經試過以下
test.request s=new test.request();
test.JBCredential jb = new test.JBCredential();
jb.code = "LNK";
jb.Username = "";
jb.Password = "";
/
s.query = "java";
s.mode = "mock_search";
s.JBCredentials.Add(jb);//I'm not getting add method
so I've tried like this
s.JBCredentials[0].code = jb.code;
s.JBCredentials[0].Password = jb.Password;
s.JBCredentials[0].Username = jb.Username;
and also I tried
List<JBCredential> ad=new List<JBCredential>();
ad.Add(jb);
s.JBCredentials=ad;
我能夠從值正常請求傳遞給JBcredentials類型但我無法通過這種類型的,當我調用Web服務。
請告訴你應該如何添加和其他代碼 – LINQ2Vodka