using System.Collections.Generic;
public static void Main()
List<A> listA = new List<A>();
listA.Add(new A { Id = 1, Email = "maria@email.com", Role = "User" });
listA.Add(new A { Id = 2, Email = "joao@email.com", Role = "Admin" });
List<B> listB = listA.Select(a => (B)a).ToList();
Console.WriteLine("Os itens da listA foram copiados para listB");
Console.WriteLine("Itens da lista A: ");
foreach (var item in listA)
Console.WriteLine(string.Format("Id {0} - E-mail: {1} - Role {2}", item.Id, item.Email, item.Role));
Console.WriteLine("Itens da lista B: ");
foreach (var item in listB)
Console.WriteLine(string.Format("Id {0} - E-mail: {1} - Role {2}", item.id_b, item.prop_b1, item.prop_b2));
public int Id { get; set; }
public string Role { get; set; }
public string Email { get; set; }
public static explicit operator A(B b)
public int id_b { get; set; }
public string prop_b1 { get; set; }
public string prop_b2 { get; set; }
public static explicit operator B(A a)