Classes with methods C#
Classes with methods Py
This is same program in Python 3.8.x
using System; namespace class_method { public class MyClass { public void method_one() { Console.WriteLine("MyClass method_one"); } public void method_two(string s1) { string Astring = s1; Console.WriteLine("MyClass method_two {0}", Astring); } } class AnotherClass : MyClass { public new void method_one() { MyClass M3 = new MyClass(); M3.method_one(); Console.WriteLine("AnotherClass method_one"); } public new void method_two(string s1) { string Astring = s1; Console.WriteLine("AnotherClass method_two {0}", Astring); } } class Program { static void Main(string[] args) { MyClass M = new MyClass(); Console.WriteLine("calling M.method_one();"); M.method_one(); Console.WriteLine(""); Console.WriteLine("calling M.method_two(This is a string to print);"); M.method_two("This is a string to print"); Console.WriteLine(""); AnotherClass M2 = new AnotherClass(); Console.WriteLine("calling M2.method_one();"); M2.method_one(); Console.WriteLine(""); Console.WriteLine("calling M2.method_two(This is a string to print);"); M2.method_two("This is a string to print"); } } }
calling M.method_one(); MyClass method_one calling M.method_two(This is a string to print); MyClass method_two This is a string to print calling M2.method_one(); MyClass method_one AnotherClass method_one calling M2.method_two(This is a string to print); AnotherClass method_two This is a string to print