> One interesting problem I found is that when the operator is not set in my
> .NET (c#) web service client the .NET studio sets a default value of "is" to
[quoted text clipped - 7 lines]
> isNot,
> }
When an Enum is defined without explicit values, then .NET assigns
values starting with 0 and increasing. So the above declaration is
actually equivalent to,
public enum SearchStringFieldOperator {
@is = 0,
isNot = 1,
}
Enums are represented as integers, and the field @operator you have
is of the SearchStringFieldOperator enum type, too. Since enums are
really integers, this field is initialized to 0, which is the same integer
value as the first enum literal in the above declaration, @is. This is
why when the Framework constructs a default SearchStringField the
@operator field already has the default value, @is.
If you want to avoid this behavior, then I'd try changing the definition
of the SearchStringFieldOperator enum.
public enum SearchStringFieldOperator {
@is = 1,
isNot,
}
This way, none of the literals of SearchStringFieldOperator correspond
to zero, which your enum fields will be initialized to by default.
Derek Harmon
Scott Liu - 28 Sep 2004 08:33 GMT
Thanks, Derek. This explains it.
The field definition is generated by .NET framework thus I do not want to
change it. The other solution then is to add a dummy field "notSet" as the 0
th enum value or to choose a default value explicitly in the schema.
Scott
> > One interesting problem I found is that when the operator is not set in my
> > .NET (c#) web service client the .NET studio sets a default value of "is" to
[quoted text clipped - 36 lines]
>
> Derek Harmon
Scott Liu - 28 Sep 2004 21:09 GMT
On second thought is there a preference in .NET which I can set to instruct
it to ignore providing a default value?
Thanks,
Scott
> Thanks, Derek. This explains it.
>
[quoted text clipped - 44 lines]
> >
> > Derek Harmon