Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Classes
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { interface IGreet { string Greet(); } public partial class Person : IGreet { public string FirstName { get; internal set; } public string LastName { get; internal set; } // Where is Greet? // public string FirstName { get; private set; } // ? } // This can be in a different file! public partial class Person : IGreet { public string Greet() { return "Hello from " + FullName; } public virtual string FullName { get { return FirstName + " " + LastName; } } } public class NicePerson : Person { public override string FullName { get { return "Nice " + base.FullName; } } // Not possible! Function not marked virtual. // public override string Greet() { // return "Nice hello from " + FullName; // } } public class Program { public static void Main(string[] args) { Person p = new Person(); p.FirstName = "Peter"; p.LastName = "P"; Console.WriteLine("Hello " + p.FirstName); Console.WriteLine(p.Greet()); //NicePerson nicep = new NicePerson() { FirstName = "Joe", LastName = "J" }; //Console.WriteLine(nicep.Greet()); } } }
run
|
edit
|
history
|
help
0
XmlException in XmlSerializer.Deserialize when XML has \0
Time by 15 minutes
adxsadxsd
first
Triple DES
shuffle2
1. Basics: primitive data types
C# Overriding example using virtual and override keywords
NumberSeenSample
ladly