imjoantoro
imjoantoro

Reputation: 1

How I can join two or more object in C#?

I want to validate a set of object and I need to make them together.

var mensajesDeValidacion = _validador.Valida();
if (!_validador.EsValido){
throw new ValidacionException("Corrija los siguientes errores", mensajesDeValidacion);}

public class Empresa : IEmpresa
{
  public int IdEmpresa{get;set;}
  public string Nombre{get;set;}
}

public interface IEmpresa
{
  int IdEmpresa{get;set;}
  string Nombre{get;set;}
}

and other class

public class ContactoEmpresa : IContactoEmpresaEmpresa
{
  public int IdContactoEmpresaEmpresa{get;set;}
  public string Direccion{get;set;}
}

public interface IContactoEmpresaEmpresa
{
  int IdContactoEmpresaEmpresa{get;set;}
  string Direccion{get;set;}
}

How i can join this two object or more?

Upvotes: 0

Views: 83

Answers (2)

Freeman
Freeman

Reputation: 5801

Tupples where introduced not long ago, you can take a look, its easy.

http://msdn.microsoft.com/en-us/library/dd268536.aspx

Upvotes: 0

burning_LEGION
burning_LEGION

Reputation: 13450

create new class with fields IEmpresa and IContactoEmpresaEmpresa or use Tuple<T1,T2>

Upvotes: 1

Related Questions