0% found this document useful (0 votes)
33 views2 pages

Using Using Using Using Namespace Class Static Void String New New

The document defines an interface for a test class with string and int methods. It then creates two classes, test1 and test2, that implement the interface. The Main method creates instances of each class and calls their saludo and suma methods, returning the string and calculating the sum respectively. test1 returns "Hola Mundo" and 15 for 7+8, while test2 returns "Hola Test2" and 35 for 15+20.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views2 pages

Using Using Using Using Namespace Class Static Void String New New

The document defines an interface for a test class with string and int methods. It then creates two classes, test1 and test2, that implement the interface. The Main method creates instances of each class and calls their saludo and suma methods, returning the string and calculating the sum respectively. test1 returns "Hola Mundo" and 15 for 7+8, while test2 returns "Hola Test2" and 35 for 15+20.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Main

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
test Ob1 = new test1();
test Ob2 = new test2();
Console.WriteLine(Ob1.saludo());
Console.WriteLine(Ob1.suma());
Console.WriteLine(Ob2.saludo());
Console.WriteLine(Ob2.suma());
Console.ReadKey();
}
}
}

Clase Padre
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
public interface test
{
string saludo();
int suma();
}
}

Clases hijas
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
class test1:test
{
public string saludo()
{
return ("Hola Mundo");
}

public int suma()


{
return(7+8);
}
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
class test2:test
{
public string saludo()
{
return ("Hola Test2");
}

public int suma() {


return(15+20);
}
}
}

You might also like