Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. XmlSerialize and nullable types

XmlSerialize and nullable types

Scheduled Pinned Locked Moved C#
xmlhelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    QzRz
    wrote on last edited by
    #1

    Hello I am new to XmlSerializing and I got a problem when trying to serialize a nullable int. The thing I serialize look like this private int? length; public int? Length { get { return this.length; } set { this.length = value; } } But when I serialize this, and it is null, the output looks like this: <Length d3p1:nil="true" xmlns:d3p1="http://www.w3.org/2001/XMLSchema-instance" /> What I want it to do is, when the int is null, I want it to be ignored and thereby not having any output to my xml-file. I could make my int to a string and then convert the string to an int whenever I need, but that doesnt seem to be a good solution to me. So, does any of you know a way to XmlSerialize an int and then if it is null, it shouldt be showed in the xml-file, or a good article/something? //QzRz

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups