Traduire ce code de VB a C#

Fermé
salma ritaje Messages postés 8 Date d'inscription samedi 13 avril 2013 Statut Membre Dernière intervention 21 mai 2013 - Modifié par durock le 4/05/2013 à 18:57
salma ritaje Messages postés 8 Date d'inscription samedi 13 avril 2013 Statut Membre Dernière intervention 21 mai 2013 - 5 mai 2013 à 15:01
bonjour a tous je veux traduire ce code de VB a C#
et quelle est le langage Le plus utilisé C# ou VB et merci d'avance

Private Sub Btn_Ajouter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Ajouter.Click
Try

Dim s As New Stagiaire

s.Nom = Txb_Nom.Text
s.Prenom = Txb_Prenom.Text
If RB_M.Checked = True Then
s.Sexe = CChar("M")
Else
s.Sexe = CChar("F")
End If
s.Optionn = CB_Option.Text
s.Age = CInt(NUD.Value)

liste_stagiaire.Add(s)


afficher_dansDG()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Private Sub BTn_Supprimer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTn_Supprimer.Click
Try

Dim indice_s As Integer = DataGridView1.CurrentRow.Index
If indice_s = liste_stagiaire.Count Then
Throw New Exception("Vous devez selectionnez une ligne")
End If
If indice_s <> liste_stagiaire.Count Then
If MessageBox.Show("Etes vous sur de vouloir supprimer le stagiaire selectionné", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
liste_stagiaire.RemoveAt(indice_s)
MessageBox.Show("Opération effectuée", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Else
MessageBox.Show("Opération annulé", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
afficher_dansDG()
Catch erreur As Exception
MsgBox(erreur.Message)
End Try
End Sub

Private Sub Btn_Rechercher_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Rechercher.Click
Dim nom As String = Txb_Nom.Text
DataGridView1.Rows.Clear()
For Each st As Stagiaire In liste_stagiaire
If st.Nom = nom Then
Txb_Nom.Text = nom
Txb_Prenom.Text = st.Prenom
If RB_F.Checked = True Then
RB_F.Checked = True
Else
RB_M.Checked = True
End If
CB_Option.Text = st.Optionn
NUD.Value = st.Age
End If
Next
End Sub


Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick

End Sub
End Class
A voir également:

2 réponses

Utilisateur anonyme
5 mai 2013 à 09:30
Sinon je te conseil d'apprendre C# car celui ci te facilitera l'apprentissage des autres langages tel que le C, C++, Java ect ayant la même syntaxe.
1
ElementW Messages postés 4816 Date d'inscription dimanche 12 juin 2011 Statut Contributeur Dernière intervention 5 octobre 2021 1 225
4 mai 2013 à 21:12
1. Ton code n'est pas complet
2. Voir ici et cliquer sur le premier lien
0
salma ritaje Messages postés 8 Date d'inscription samedi 13 avril 2013 Statut Membre Dernière intervention 21 mai 2013
5 mai 2013 à 15:01
oui je sais et merci pour le site
0