@ Майк, так что вы должны использовать сопоставление с образцом вместо проверки на нуль.
я перехожу через следующий код,report
во второй строке ноль. Однако третья строка генерирует исключение NullReferenceException.
member this.setTaggedResearchReportList (index : int) (taggedResearchReport : TaggedResearchReportUIVO option) =
let report = Option.get(taggedResearchReport)
if not(report.Equals(null)) then
// do some stuff here
Почему это так, и что я могу сделать, чтобы избежать этого? Спасибо!
Добавлено позже:Вот строка, которая вызываетthis.setTaggedResearchReportList
:
getMostRecentTaggedResearchReportForSecurityId (item.id) (new Action<_>(this.setTaggedResearchReportList 0))
ВотgetMostRecentTaggedResearchReportForSecurityId
метод:
let getMostRecentTaggedResearchReportForSecurityId (securityId : int) (callbackUI : Action<_>) =
getSingleRPCResult<JSONSingleResult<TaggedResearchReportUIVO>, TaggedResearchReportUIVO>
"TaggedResearchReportRPC"
"getMostRecentResearchReportForSecurityId"
(sprintf "%i" securityId)
callbackUI
(fun (x : option<JSONSingleResult<TaggedResearchReportUIVO>>) ->
match x.IsSome with
| true -> Some(Option.get(x).result)
| false -> None
)