user348173
user348173

Reputation: 9288

Problem with operator?

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, tbNameRu not found, because they are inside Panel control.

Upvotes: 0

Views: 70

Answers (2)

Mr47
Mr47

Reputation: 2655

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

Upvotes: 1

Incognito
Incognito

Reputation: 16597

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

Upvotes: 3

Related Questions