J'ai un petit problème de syntaxe que je n'arrive pas à résoudre.
Je convertis une classe VB.NET en C#. Dans la classe initiale, j'ai ceci:
Je souhaite convertir ceci et écrit donc ceci: (après lecture de http://terrysmith.net/software/dotnet_ebook/chapter3.html)
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 // déclaration de la propriété [classe CMContacts] Public ReadOnly Property Item(ByVal iRowId As Integer) As CMContact Get Dim objContact As CMContact For Each objContact In InnerList If objContact.id.ToString = iRowId.ToString Then Return objContact End If Next Return Nothing End Get End Property (...) // appel objContact = CType(Me.Item(iRowGuid), CMContact)
Vous aurez compris que je me demande comment écrire l'appel correctement (ce qui n'est actuellement pas le cas)...
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 // déclaration de la propriété [classe CMContacts] public CMContact this[System.Guid iRowId] { get { foreach(CMContact objContact in InnerList) { if (objContact.id.ToString() == iRowId.ToString()) { return objContact; } } return null; } } (...) // appel CMContacts cmc; objContact = cmc(iRowGuid); // ne fonctionne pas:
Partager