System.NullReferenceException:對象不設置到對象的實例谷歌API:讓空上陣
UserOrganization[] newuserorg = new UserOrganization[10];
newuserorg[0].CostCenter = "test";
newuserorg[1].Department = "test";
newuserorg[2].Description = "test";
newuserorg[3].Domain = "demo.com";
newuserorg[4].Symbol = "TWW";
newuserorg[5].Primary = true;
newuserorg[6].Title = "title";
newuserorg[7].Type = "work";
newuserorg[8].Name = "HEY";
newuserorg[9].Location = "PH";
newuserbody.Organizations = newuserorg;
service.Users.Update(newuserbody, email).Execute();
我得到空值newuserorg [0] .CostCenter
我使用Google Admin API和C#更新用戶的組織詳細信息。 謝謝。
UPDATE:現在有效,我只是忘了實例化。謝謝。
的可能重複[什麼是一個NullReferenceException,我如何修復它?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) –
提供UserOrganization代碼 –
你永遠不會實例化一個'UserOrganization',所以你'在'null'上設置屬性。 –