开发者

Problem with operator?

开发者 https://www.devze.com 2023-03-29 00:49 出处:网络
I am writing following code: _normDoc = value as NormDoc; if(_normDoc != null) { ucRusKazTextBoxesAnnotation.Controls[\"tbNameRu\"].Text = _normDoc.AddInfoRu ?? string.Empty;

I am writing following code:

_normDoc = value as NormDoc;
  if(_normDoc != null)
   {
     ucRusKazTextBoxesAnnotation.Controls["tbNameRu"].Text = _normDoc.AddInfoRu ?? string.Empty;
   }

I think that if _normDoc.AddInfoRu == null then ucRusKazTextBoxesAnnotation.Controls["tbNameRu"].Text will be equal empty string.

But I am got error: NullReferenceException. Can you explain me why?

PS. ucRusKazTextBoxesAnnotation not equal null;

EDIT: Sorry, I find error, yes, tbNa开发者_如何学PythonmeRu not found, because they are inside Panel control.


Make sure that ucRusKazTextBoxesAnnotation.Controls["tbNameRu"] is not null.


ucRusKazTextBoxesAnnotation.Controls["tbNameRu"] could be null just as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号