Skip to content

Instantly share code, notes, and snippets.

@mythz mythz/main.cs
Created Oct 30, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.