Skip to content

Instantly share code, notes, and snippets.

@dontpaniclabsgists
Created March 18, 2025 17:09
Show Gist options
  • Save dontpaniclabsgists/f9d61ca23cdbb5347cf0f21a52b9e91c to your computer and use it in GitHub Desktop.
Save dontpaniclabsgists/f9d61ca23cdbb5347cf0f21a52b9e91c to your computer and use it in GitHub Desktop.
public class Person
{
[XmlElement(ElementName = "First")]
public string FirstName { get; set; }
[XmlElement(ElementName = "Last")]
public string LastName { get; set; }
public int Age { get; set; }
[XmlElement(IsNullable = true)]
public string Email { get; set; }
public PhoneNumber[] PhoneNumbers { get; set; }
public bool ShouldSerializeAge()
{
// Only serialize Age if 18 or older
return Age >= 18;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment