Bonjour, je suis en train de bloquer sur un programme, j'ai une problème d’instanciation d'objet, je colle ici mon code.
J'ai un problème avec cette aspect du C#, c'est sans doute un truc stupide mais je bloque depuis un moment. Merci d'avance
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
24
25
26
27
28
29 class Program { static void Main(string[] args) { GetFonction("StringType"); } public static S_E GetFonction(string Val) { string[] array = new string[] { "zero", "un", "deux" }; string[] array2 = new string[] { "Desc0", "Desc1", "Desc2" }; sous_ensemble SE = new sous_ensemble(); SE.Statut="Mon status";//OK for (int i = 0; i < 3; i++) { SE.Numero.Add(array[i]);//ici //La référence d'objet n'est pas définie à une instance d'un objet. SE.Descri .Add(array2[i]); } return SE; } } public class S_E { public string Statut { get; set; } public List<string> Numero{ get; set; } public List<string> Descri { get; set; } }
Partager