Send parameters to a C #

2

I created a class called descricaoo that will receive some data parameters and will add in a List of an interface called IInstrucao . But it gives an error "the description class is not implemented to an interface" How to correct this error? Is there another way to send this data directly into the IInstrucao interface?

class descricaoo:IInstrucao
{
   private string descricaobol;
   public descricaoo (int ibanco, int codigo, string descricaobol, int qtde)
   {
     this.descricaobol = descricaobol;
     List<IInstrucao> desci = new List<IInstrucao>();
     desci.Add(new descricaoo(ibanco,codigo,descricaobol,qtde));
   }  
 }

public interface IInstrucao
{
    IBanco Banco { get; set; }
    int Codigo { get; set; }
    string Descricao { get; set; }
    int QuantidadeDias { get; set; }
}
    
asked by anonymous 29.10.2015 / 16:33

2 answers

4

You're saying to implement the interface, so do this:

using System.Collections.Generic;

public class Program {
    public static void Main() {
    }
}

class descricaoo : IInstrucao {
    private string descricaobol;
    public descricaoo (int ibanco, int codigo, string descricaobol, int qtde) {
        this.descricaobol = descricaobol;
        List<IInstrucao> desci = new List<IInstrucao>();
        desci.Add(new descricaoo(ibanco,codigo,descricaobol,qtde));
    }
    public IBanco Banco { get; set; }
    public int Codigo { get; set; }
    public string Descricao { get; set; }
    public int QuantidadeDias { get; set; }
}

public interface IInstrucao {
    IBanco Banco { get; set; }
    int Codigo { get; set; }
    string Descricao { get; set; }
    int QuantidadeDias { get; set; }
}

public interface IBanco {}

See compiling in dotNetFiddle .

    
29.10.2015 / 16:39
2

You need to define all interface items in the class, as enunciates the C # contract architecture :

class descricaoo: IInstrucao
{
   private string descricaobol;
   public descricaoo (int ibanco, int codigo, string descricaobol, int qtde)
   {
     this.descricaobol = descricaobol;
     List<IInstrucao> desci = new List<IInstrucao>();
     desci.Add(new descricaoo(ibanco,codigo,descricaobol,qtde));
   }  

    public IBanco Banco { get; set; }
    public int Codigo { get; set; }
    public string Descricao { get; set; }
    public int QuantidadeDias { get; set; }
 }

public interface IInstrucao
{
    IBanco Banco { get; set; }
    int Codigo { get; set; }
    string Descricao { get; set; }
    int QuantidadeDias { get; set; }
}
    
29.10.2015 / 16:39