Convert "Nothing" to an empty string?

  • Thread starter Thread starter Larry Bud
  • Start date Start date
L

Larry Bud

Using XML serializer, if an XML field is missing, then the value in
the object is Nothing.

Is there a slick way of converting a "Nothing" to an empty string
without doing is

if x is nothing then...
 
Just make your default as empty string.

Example

class clsMyClass
{
public string Id="";
}

then when desirializing it with XML Serializer the field will be set to ""
(Basically left untouched)

George.
 
Just make your default as empty string.

Example

class clsMyClass
{
    public string Id="";

}

then when desirializing it with XML Serializer the field will be set to ""
(Basically left untouched)

George.

The only problem with that is that the class file is being generated
by the XSD.EXE tool, from a very large schema (over 30 tables)
 
So? You use XSD only once are not you?
Just go and modify the source files it had generated after.

George.

Just make your default as empty string.

Example

class clsMyClass
{
public string Id="";

}

then when desirializing it with XML Serializer the field will be set to ""
(Basically left untouched)

George.

The only problem with that is that the class file is being generated
by the XSD.EXE tool, from a very large schema (over 30 tables)
 
So?  You use XSD only once are not you?
Just go and modify the source files it had generated after.

George.




The only problem with that is that the class file is being generated
by the XSD.EXE tool, from a very large schema (over 30 tables)- Hide quoted text -

That's true, except that our customer controls the schema, and it can
change fairly regularly. Which would mean modifying the class file
every time.
 
re:
!> except that our customer controls the schema, and it can change fairly regularly.
!> Which would mean modifying the class file every time

I'd hate to work as a programmer in a place where that happens "fairly regularly".




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
So? You use XSD only once are not you?
Just go and modify the source files it had generated after.

George.




The only problem with that is that the class file is being generated
by the XSD.EXE tool, from a very large schema (over 30 tables)- Hide quoted text -

That's true, except that our customer controls the schema, and it can
change fairly regularly. Which would mean modifying the class file
every time.
 
Well, you out of luck then.

Write your own initialization function that sets defaults right after
deserialization.

George.

So? You use XSD only once are not you?
Just go and modify the source files it had generated after.

George.




The only problem with that is that the class file is being generated
by the XSD.EXE tool, from a very large schema (over 30 tables)- Hide
quoted text -

That's true, except that our customer controls the schema, and it can
change fairly regularly. Which would mean modifying the class file
every time.
 
Well, you out of luck then.

Write your own initialization function that sets defaults right after
deserialization.

George.






That's true, except that our customer controls the schema, and it can
change fairly regularly.  Which would mean modifying the class file
every time.- Hide quoted text -

- Show quoted text -

Is there a semi-easy way of doing that, such as iterating through each
object?
 
Back
Top