crmFactory.RegisterDemoAccount
拋出Exception
使用未賦值的變量。爲了使用變量res
我需要初始化它。C# - 如何try catch塊
由於AccountRegistrationResponse
不可初始化,我如何聲明res
而不會收到有關使用未分配變量的編譯錯誤? 我可以將它分配給null,但我認爲這不是一個好的編程方法。
AccountRegistrationResponse res /*=null*/;
try
{
res = crmFactory.RegisterDemoAccount(CrmConfigRepository.CrmOwnerUserId
, CrmConfigRepository.CrmOrganizationName
, CrmConfigRepository.CrmBusinessUnitName
, demo.getData());
}
catch (Exception e)
{
_log.Error("Cannot create demo account", e);
}
_log.Debug(res.getString());