I am currently studying on multiple inheriting operation.What ihave learnt is we can’t inherit multiple class but we can inherit a class and an interface so i just need to switch a class to an interface. Like below
class a{} class b{} interface d{} //class c:a,b{} That does not work //class c:a,d{} or class c:b,d{} but these need to work
If i return to my question respect for multiple inheritance operation, Here is an complete program that explains my problem.
using System; using System.Collections.Generic; using System.Text; namespace interface_ile_multiple_inheritance { interface set_get { double _getx { get; } double _gety { get ; } protected double total;//I want to use it by inheriting } class set_items { protected double x; protected double y; public set_items(double _x, double _y) { x = _x; y = _y: } } class display : set_items, set_get { public display(double x, double y) : base(x, y) { } public double _getx { get { return x; } } public double _gety { get { return y; } } public double total_res() { total = x + y; // Error line 1 total does not exist return total; //Error line 2 total does not exist } } class Program { static void Main(string[] args) { display disp1 = new display(12, 12); Console.WriteLine("Total:" + disp1.total_res().ToString());//HERE İ NEED TO FİND x+y Console.WriteLine("Area:" + (disp1._getx * disp1._gety).ToString());//HERE İ NEED TO FİND x*y } }
}
Even though i can inherit interface’s property signatures,why can’t i inherit its integer variable?