Bonjour
Je me suis bloqué au niveaux d'une conversion d'une liste d'interface à son propre classe.
La 2ème interface qui parmi de ces attributs un de type IField.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 /*Interface IField*/ public interface IField { string FieldName { get; set; } string FieldType { get; set; } } /*Son implémentation*/ public class Field : IField { public Field(string fieldName, string fieldType) { this.FieldName = fieldName; this._fieldType = fieldType; } public string FieldName { get ; set; } public string FieldType{ get ; set; } }
Ce que je veux c'est convertir la liste de IField en liste de Field pour avoir un constructeur où FieldList est de type List<Field> comme:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 public interface IProtocol { string NameProtocol { get; set; } string Id { get; set; } List<IField> FieldList { get; set; } } /*Son implémentation*/ public class Protocol : IProtocol { public Protocol(string nameProtocol, string id, List<IField> fieldList) { this.NameProtocol = nameProtocol; this.Id = id; this.FieldList = fieldList; } public string NameProtocol{ get ; set; } public string Id{ get ; set; } public List<IField> FieldList{ get ; set; } }
Le problème si j'utilise le 2eme constructeur j'aurais un problème d'implémentation car son Interface possède une liste de IField.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 public Protocol(string nameProtocol, string id, List<Field> fieldList) { this.NameProtocol = nameProtocol; this.Id = id; this.FieldList = fieldList; } public List<Field> FieldList{ get ; set; }
Celle la sa marche: IField Ifield = new Field();
Mais celle ci non: List<IField> fields = new List<Field>(); "Err convertion"
Avez vous de solution?
Merci
Cordialement
Partager