0

Basically, I want to pass back the following in my WCF service:

[DataMember(IsRequired = true)]
IDictionary<int, MyObj> objects { get; set; }

How can I make it so that the MyObj can be null so that when I receive it on the other end it doesn't instantiate a blank item, but instead leaves it null?

michael
  • 14,844
  • 28
  • 89
  • 177

1 Answers1

3

It can be null, you don't need to do anything special. The IsRequired=true applies to the dictionary itself, not to specific instances of the dictionary.

Also, you shouldn't use IDictionary (unless you want to deal with [KnownType]s), Dictionary should do fine.

carlosfigueira
  • 85,035
  • 14
  • 131
  • 171