Skip to content

Instantly share code, notes, and snippets.

@mythz
Created October 30, 2018 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mythz/a9ded232cbe3f1a6c185219efe30e669 to your computer and use it in GitHub Desktop.
Save mythz/a9ded232cbe3f1a6c185219efe30e669 to your computer and use it in GitHub Desktop.
Rename inherited member in Sub class
using System.Linq;
using System.Runtime.Serialization;
using ServiceStack;
using ServiceStack.Text;
[DataContract]
public class Parent
{
[DataMember(Name = "parentItem")]
public virtual string Item { get; set; }
}
[DataContract]
public class Child : Parent
{
[DataMember(Name = "childItem")]
public override string Item { get; set; }
}
var json1 = new Parent { Item = "parent" }.ToJson();
json1.Print();
var json2 = new Child { Item = "child" }.ToJson();
json2.Print();
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ServiceStack.Text" version="5.2.0" targetFramework="net45" />
<package id="ServiceStack.Client" version="5.2.0" targetFramework="net45" />
<package id="ServiceStack.Interfaces" version="5.2.0" targetFramework="net45" />
</packages>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment