Bonjour,
J'ai un petit problème de casting d'objet.
Dans mon code j'ai 2 definitions d'object ayant la même format.
Les objects aaa et bbb
-------------------------------------
public partial class aaa
{
private string nom;
private string prenom;
//GET AND SET
public string lenom
{
get
{
return this.nom;
}
set
{
this.nom = value;
}
}
public string leprenom
{
get
{
return this.prenom;
}
set
{
this.prenom = value;
}
}
}
public partial class bbb
{
private string nom;
private string prenom;
//GET AND SET
public string lenom
{
get
{
return this.nom;
}
set
{
this.nom = value;
}
}
public string leprenom
{
get
{
return this.prenom;
}
set
{
this.prenom = value;
}
}
}
--------------------------------
Je voudrais remplir un object de type aaa et le copier (via un casting) dans un object de type bbb avec le code suivant:
-----------------------------
aaa testA = new aaa();
bbb testB = new bbb();
testA.lenom = "Brika";
testA.leprenom = "Remi";
testB = (bbb)testA;
---------------------------
Avec ce code j'obtiens l'erreur "cannot convert type 'aaa' to 'bbb' "
Mes objects réels dans mon code son beaucoup plus grand c'est pourquoi je voudrais éviter de copier tous les parametres 1 par 1 d'un object à un autre.
Pouvez-vous me dire comment serait-il possible de résoudre ce problème?
Merci d'avance pour votre aide.

Alain
-----------------------------
Remi