Convert "Nothing" to an empty string?

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...
 
G

George Ter-Saakov

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.
 
L

Larry Bud

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)
 
G

George Ter-Saakov

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)
 
L

Larry Bud

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.
 
J

Juan T. Llibre

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".





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.
 
G

George Ter-Saakov

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.
 
L

Larry Bud

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,125
Latest member
VinayKumar Nevatia_
Top