CSharp · Console
using System;
using System.Linq;
public class Program
{
public static void Main()
{
Console.WriteLine(new Teste2().AnyMethod(1, 2));
Console.WriteLine(new Teste2().AnyMethod(1, 2, 3));
Console.WriteLine(new Teste2().AnyMethod(1, 2, 3, 4));
}
}
public abstract class Teste
{
public virtual int AnyMethod(params int[] lista)
{
throw new NotImplementedException ( "This method is not implemented" );
}
}
public class Teste2: Teste
{
public override int AnyMethod(params int[] lista)
{
return lista.Sum(x => x);
}
public int AnyMethod(int a, int b)
{
return AnyMethod(new int[] {a, b});
}
public new int AnyMethod(int a, int b, int c)
{
Console.WriteLine("Exemplo do new");
return a + b + c;
}
}