Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace CovariantReturnType
- {
- class SkillsBase {
- public int Salute { get; set; } = 10;
- }
- class Personaggio {
- SkillsBase sb = new SkillsBase();
- public virtual SkillsBase GetSkills()
- {
- return sb;
- }
- }
- class SkillsRPG : SkillsBase{
- public int SaluteExtra { get; set; } = 0;
- }
- class PersonaggioRPG : Personaggio {
- public SkillsRPG Skills = new SkillsRPG();
- public override SkillsRPG GetSkills()
- {
- return Skills;
- }
- }
- internal class Program
- {
- static void Main(string[] args)
- {
- Personaggio p = new Personaggio();
- SkillsBase skills = p.GetSkills();
- PersonaggioRPG pRPG = new PersonaggioRPG();
- SkillsRPG skillsRPG = pRPG.GetSkills();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement