Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
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
Please
log in
to post a comment.
Game 1.0.2
Umbraco
services
Move 2 ushort to 1 int
Order of Ops 6.5 (added brackets)
Test
tamrin
Combustible SetUp
Project Euler Problem 4
Knapsack Problem
stackse - search stackoverflow differently
Please log in to post a comment.