Skip to content

Commit

Permalink
# a bit of inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
nahiandev committed Dec 4, 2024
1 parent 4383a03 commit d4bb447
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 31 deletions.
20 changes: 20 additions & 0 deletions DomeTrain/Base.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Threading.Channels;

namespace DomeTrain
{
public class Base
{
// public virtual void Print(string text);

public virtual void PrintConsole() => Console.WriteLine("Base class method.");
}

public class Instance : Base
{
public void PrintConsoleBase() => base.PrintConsole();

// public override void PrintConsole() => base.PrintConsole();

public override void PrintConsole() => Console.WriteLine("Derived class method.");
}
}
19 changes: 0 additions & 19 deletions DomeTrain/Person.cs

This file was deleted.

19 changes: 7 additions & 12 deletions DomeTrain/Program.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
namespace DomeTrain
using System.IO.Compression;

namespace DomeTrain
{
class Program
{
static void Main()
{
Instance r = new();

var VT = (1, 2, 3, 4, 5, "RE", 'E', true, 1.2, 1.3f);


List<int> nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

var (_, max) = MinMax(nums);
r.PrintConsoleBase();
r.PrintConsole();

Console.WriteLine(max);

Console.WriteLine(r is Base);
}

private static (int Min, int Max) MinMax(List<int> nums) => (nums.Min(), nums.Max());

}
}

0 comments on commit d4bb447

Please sign in to comment.