IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C# Discussion :

classe en c#


Sujet :

C#

  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 37
    Par défaut classe en c#
    Bonjour à tous
    Je viens vous demander de l'aide car je bloque totalement
    Je dois créer des classes métiers pour un projet en C# sur .NET mais je ne vois pas comment m'y prendre
    Par exmple dans mon diagramme d'utilisation , j'ai ceci

    ------------
    équipement réseau
    ---------------
    adresse_ip
    login
    mot_de_passe
    ------------
    exécuter commande()
    ----------


    Pour moi ce langage est tout nouveau
    J'ai cherché sur le net mais je ne trouve pas beaucoup d'exemple pour m'aider
    Merci d'avance

  2. #2
    Expert confirmé

    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Septembre 2006
    Messages
    3 580
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Septembre 2006
    Messages : 3 580
    Par défaut
    Salut vincent

    sur ce site, tu trouveras un cours très complet sur C#...

    Commence par le téléchargé et le lire... et beaucoup de questions que tu as trouveront des réponses dans ce document

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 37
    Par défaut
    ok je vais voir ça mais je laisse le topic ouvert

  4. #4
    Membre actif
    Profil pro
    Étudiant
    Inscrit en
    Janvier 2011
    Messages
    57
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2011
    Messages : 57
    Par défaut
    Pour crée un classe il faut faire ça


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
     
     [Public , private ....]  class [Nom de ta classe]
    {
        [public ....] string IpMachine; // déclarer tes variable
     
    	public [Nom de ta classe]// le constructeur
    	{
    		//
    		// TODO: ajoutez ici la logique du constructeur
    		//
    	}
    }
    en suite à toi de jouer copain !

    bonne chance

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 37
    Par défaut
    voilà ce que j'ai fais pour le moment


    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
     
     
     
     
    using System;
     
    namespace ConsoleApplication2
    {
    	/// <summary>
    	/// Description résumée de equipement_reseau.
    	/// </summary>
    	public class equipement_reseau
    	{
    			// atributs 
    			private int adresse_ip;
    			private int login; 
    			private int mot_de_passe; 
     
    			//methode 
    			public void executer_commande (int ap , int l , int mdp){
    				this.adresse_ip=ap; 
    				this.login=l; 
    				this.mot_de_passe=mdp; 
     
    	}
     
    	}
    }

  6. #6
    Membre actif
    Profil pro
    Étudiant
    Inscrit en
    Janvier 2011
    Messages
    57
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2011
    Messages : 57
    Par défaut
    tu as oublier de faire un constructeur

    il est impératif de le faire !

  7. #7
    Rédacteur
    Avatar de WOLO Laurent
    Homme Profil pro
    Architecte de base de données
    Inscrit en
    Mars 2003
    Messages
    2 741
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Congo-Brazzaville

    Informations professionnelles :
    Activité : Architecte de base de données
    Secteur : Finance

    Informations forums :
    Inscription : Mars 2003
    Messages : 2 741
    Par défaut
    Pas vraiment nécessairement si on ne sait pas à quoi ca va servir.
    De toutes façons, il y'a toujours un constructeur par défaut.

    Découvrez la FAQ de MS SQL Server.
    La chance accorde ses faveurs aux esprits avertis !

  8. #8
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    206
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 206
    Par défaut
    Oublier le constructeur n'est pas forcément gênant, mais par contre, qu'attends tu comme retour à ton dernier message ?

    Rencontres tu un problème de fonctionnement ?

  9. #9
    Membre averti
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 37
    Par défaut
    Quand je débugge , j'ai une console qui s'ouvre et qui se referme aussitôt

  10. #10
    Rédacteur
    Avatar de WOLO Laurent
    Homme Profil pro
    Architecte de base de données
    Inscrit en
    Mars 2003
    Messages
    2 741
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Congo-Brazzaville

    Informations professionnelles :
    Activité : Architecte de base de données
    Secteur : Finance

    Informations forums :
    Inscription : Mars 2003
    Messages : 2 741
    Par défaut
    Oui, normal, tu n'as fait que créer ta classe, il te faut également l'instancier puis l'utiliser dans une procedure main() dans ton cas

    Découvrez la FAQ de MS SQL Server.
    La chance accorde ses faveurs aux esprits avertis !

  11. #11
    Membre averti
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 37
    Par défaut
    ok je testerais sa demain en projet au lycée
    Merci de votre aide
    Je vous tiens au courant demain

  12. #12
    Membre averti
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 37
    Par défaut
    bon je suis en projet et je viens d'essayer ça , mais j'ai toujours une fenêtre noire

    dans le code de ma classe equipement_reseau.cs, j'ai ce code là :


    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
    30
    31
    32
    33
     
    using System;
     
    namespace ConsoleApplication2
    {
    	/// <summary>
    	/// Description résumée de equipement_reseau.
    	/// </summary>
    	public class equipement_reseau
    	{
    			// atributs 
    			private int adresse_ip;
    			private string login; 
    			private string mot_de_passe; 
     
    			//methode 
    			public void executer_commande ( int aIp , string l , string mdp){
    			    this.adresse_ip=aIp; 
    				this.login=l; 
    				this.mot_de_passe=mdp; 
    			}
     
     
    	    	public void executer ()
    		    {
    	 			 Console.WriteLine("[ {0}, {1}, {2}]", adresse_ip, login, mot_de_passe);
    		    }
     
     
     
     
    	}
    }
    Et sur mon fichier Class1.cs j'ai ceci :


    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
     
     
     
    using System;
     
    namespace ConsoleApplication2
    {
    	/// <summary>
    	/// Description résumée de Class1.
    	/// </summary>
    	class Class1
    	{
    		/// <summary>
    		/// Point d'entrée principal de l'application.
    		/// </summary>
    		[STAThread]
    		static void Main(string[] args)
    		{
    		 equipement_reseau ep1= new equipement_reseau();
             Console.ReadLine();
    		}
    	}
    }

    Merci de votre aide

  13. #13
    Membre éclairé
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    47
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Juillet 2009
    Messages : 47
    Par défaut
    Il faut appeler ta méthode executer sur l'objet ep1 :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    [STAThread]
    static void Main(string[] args)
    {
              equipement_reseau ep1= new equipement_reseau();
              ep1.executer();          
              Console.ReadLine();
    }
    Edit : et il faudra que tu initialises tes attributs (soit via un constructeur soit via ta méthode executer_commande().

  14. #14
    Membre averti
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 37
    Par défaut
    salut
    Peux tu me dire comment on fait le constructeur au de ma méthode stp ?
    J'ai cherché de mon coté en lisant le cours mais j'y arrive pas du tout
    Je continue à cherche

  15. #15
    Membre éclairé
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    47
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Juillet 2009
    Messages : 47
    Par défaut
    Tu as tout ce qu'il te faut là : http://msdn.microsoft.com/fr-fr/libr...(v=vs.80).aspx

  16. #16
    Membre averti
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 37
    Par défaut
    ok merci je reargarde et si j'ai des problèmes je reviens

  17. #17
    Membre averti
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 37
    Par défaut
    Bonjour , je reviens vous demander de l'aide

    Donc voilà je suis en projet et j'ai codé ceci CEquipementRéseau

    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
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    using System;
    using MinimalisticTelnet;
    using TestTelnet;
     
    namespace TestTelnet
    {
    	/// <summary>
    	/// Description résumée de CEquipementRéseau.
    	/// </summary>
    	public class CEquipementRéseau
    	{
    		// attributs de la classe : 
     
    	    static protected  string adresse_ip;
    		static protected string login; 
    		static protected string mot_de_passe; 
    		static protected int numero_de_port; 
    		private TelnetConnection TC;
     
    		// constructeur de la classe: 
     
    		public void CequipementRéseau  (string  adresseIp , string l , string mdp, int NumeroDePort)
    		{
    			adresse_ip=adresseIp; 
    			login=l; 
    			mot_de_passe=mdp; 
    			numero_de_port=NumeroDePort; 
    		}
     
    		public string Connecter()
    		{
    			//numero du port
    			int NumeroDePort = 23;
    			//creation d'un nouvel object TelnetConnection
    			TC = new TelnetConnection(adresse_ip, NumeroDePort);
     
    			string s = TC.Login(login, mot_de_passe, 300);
     
    			//pour test en debugage
    			Console.Write(s);
     
    			// server output should end with "$" or ">",
    			//otherwise the connection failed
    			// enlever espaces à la fin
    			string prompt = s.TrimEnd();
    			// prendre dernier caractère
    			prompt = s.Substring(prompt.Length -1,1);
    			if (prompt != "$" && prompt != ">" )
    				throw new Exception("Connection failed");
     
    			return("Connexion Effectuée !!");
    		}
     
    	}
    }
    Ensuite dans ma form1.cs:


    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
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
     
     
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
     
    using MinimalisticTelnet;
     
     
    using System.Text;
    using System.Net.Sockets;
     
    namespace TestTelnet
    {
    	/// <summary>
    	/// Description résumée de Form1.
    	/// </summary>
    	public class Form1 : System.Windows.Forms.Form
    	{
    		private System.Windows.Forms.Label lbAdresseIp;
    		private System.Windows.Forms.TextBox textBoxAdresseIp;
    		private System.Windows.Forms.Label lbLogin;
    		private System.Windows.Forms.TextBox textBoxLogin;
    		private System.Windows.Forms.Label label1;
    		private System.Windows.Forms.TextBox textBoxMotDePasse;
    		private System.Windows.Forms.Label lbEntrerCommande;
    		private System.Windows.Forms.TextBox textBoxEntrerCommande;
    		private System.Windows.Forms.Button btConstruire;
    		private System.Windows.Forms.Button btConnecter;
    		private System.Windows.Forms.Button btDéconnecter;
    		private System.Windows.Forms.Button btExécuterCommande;
    		private System.Windows.Forms.Label lbTexteRetour;
     
     
    		private CEquipementRéseau EquipementRéseau;
    		/// <summary>
    		/// Variable nécessaire au concepteur.
    		/// </summary>
    		private System.ComponentModel.Container components = null;
     
    		public Form1()
    		{
    			//
    			// Requis pour la prise en charge du Concepteur Windows Forms
    			//
    			InitializeComponent();
     
    			//
    			// TODO : ajoutez le code du constructeur après l'appel à InitializeComponent
    			//
    		}
     
    		/// <summary>
    		/// Nettoyage des ressources utilisées.
    		/// </summary>
    		protected override void Dispose( bool disposing )
    		{
    			if( disposing )
    			{
    				if (components != null) 
    				{
    					components.Dispose();
    				}
    			}
    			base.Dispose( disposing );
    		}
     
    		#region Code généré par le Concepteur Windows Form
    		/// <summary>
    		/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
    		/// le contenu de cette méthode avec l'éditeur de code.
    		/// </summary>
    		private void InitializeComponent()
    		{
    			this.lbAdresseIp = new System.Windows.Forms.Label();
    			this.textBoxAdresseIp = new System.Windows.Forms.TextBox();
    			this.lbLogin = new System.Windows.Forms.Label();
    			this.textBoxLogin = new System.Windows.Forms.TextBox();
    			this.label1 = new System.Windows.Forms.Label();
    			this.textBoxMotDePasse = new System.Windows.Forms.TextBox();
    			this.lbEntrerCommande = new System.Windows.Forms.Label();
    			this.textBoxEntrerCommande = new System.Windows.Forms.TextBox();
    			this.btConstruire = new System.Windows.Forms.Button();
    			this.btConnecter = new System.Windows.Forms.Button();
    			this.btDéconnecter = new System.Windows.Forms.Button();
    			this.btExécuterCommande = new System.Windows.Forms.Button();
    			this.lbTexteRetour = new System.Windows.Forms.Label();
    			this.SuspendLayout();
    			// 
    			// lbAdresseIp
    			// 
    			this.lbAdresseIp.Location = new System.Drawing.Point(8, 24);
    			this.lbAdresseIp.Name = "lbAdresseIp";
    			this.lbAdresseIp.Size = new System.Drawing.Size(96, 16);
    			this.lbAdresseIp.TabIndex = 0;
    			this.lbAdresseIp.Text = "Adresse Ip";
    			// 
    			// textBoxAdresseIp
    			// 
    			this.textBoxAdresseIp.Location = new System.Drawing.Point(152, 32);
    			this.textBoxAdresseIp.Name = "textBoxAdresseIp";
    			this.textBoxAdresseIp.Size = new System.Drawing.Size(232, 20);
    			this.textBoxAdresseIp.TabIndex = 1;
    			this.textBoxAdresseIp.Text = "textBoxAdresseIp";
    			// 
    			// lbLogin
    			// 
    			this.lbLogin.Location = new System.Drawing.Point(8, 72);
    			this.lbLogin.Name = "lbLogin";
    			this.lbLogin.Size = new System.Drawing.Size(88, 16);
    			this.lbLogin.TabIndex = 2;
    			this.lbLogin.Text = "Login";
    			// 
    			// textBoxLogin
    			// 
    			this.textBoxLogin.Location = new System.Drawing.Point(152, 72);
    			this.textBoxLogin.Name = "textBoxLogin";
    			this.textBoxLogin.Size = new System.Drawing.Size(232, 20);
    			this.textBoxLogin.TabIndex = 3;
    			this.textBoxLogin.Text = "textBoxLogin";
    			// 
    			// label1
    			// 
    			this.label1.Location = new System.Drawing.Point(8, 112);
    			this.label1.Name = "label1";
    			this.label1.Size = new System.Drawing.Size(88, 16);
    			this.label1.TabIndex = 4;
    			this.label1.Text = "Mot de Passe";
    			// 
    			// textBoxMotDePasse
    			// 
    			this.textBoxMotDePasse.Location = new System.Drawing.Point(152, 112);
    			this.textBoxMotDePasse.Name = "textBoxMotDePasse";
    			this.textBoxMotDePasse.Size = new System.Drawing.Size(232, 20);
    			this.textBoxMotDePasse.TabIndex = 5;
    			this.textBoxMotDePasse.Text = "textBoxMotDePasse";
    			// 
    			// lbEntrerCommande
    			// 
    			this.lbEntrerCommande.Location = new System.Drawing.Point(8, 152);
    			this.lbEntrerCommande.Name = "lbEntrerCommande";
    			this.lbEntrerCommande.Size = new System.Drawing.Size(112, 16);
    			this.lbEntrerCommande.TabIndex = 6;
    			this.lbEntrerCommande.Text = "Entrer Commande";
    			// 
    			// textBoxEntrerCommande
    			// 
    			this.textBoxEntrerCommande.Location = new System.Drawing.Point(152, 152);
    			this.textBoxEntrerCommande.Name = "textBoxEntrerCommande";
    			this.textBoxEntrerCommande.Size = new System.Drawing.Size(232, 20);
    			this.textBoxEntrerCommande.TabIndex = 7;
    			this.textBoxEntrerCommande.Text = "textBoxEntrerCommande";
    			// 
    			// btConstruire
    			// 
    			this.btConstruire.Location = new System.Drawing.Point(448, 8);
    			this.btConstruire.Name = "btConstruire";
    			this.btConstruire.Size = new System.Drawing.Size(136, 24);
    			this.btConstruire.TabIndex = 8;
    			this.btConstruire.Text = "Construire";
    			this.btConstruire.Click += new System.EventHandler(this.btConstruire_Click);
    			// 
    			// btConnecter
    			// 
    			this.btConnecter.Location = new System.Drawing.Point(448, 56);
    			this.btConnecter.Name = "btConnecter";
    			this.btConnecter.Size = new System.Drawing.Size(136, 24);
    			this.btConnecter.TabIndex = 9;
    			this.btConnecter.Text = "Connecter";
    			this.btConnecter.Click += new System.EventHandler(this.btConnecter_Click);
    			// 
    			// btDéconnecter
    			// 
    			this.btDéconnecter.Location = new System.Drawing.Point(448, 104);
    			this.btDéconnecter.Name = "btDéconnecter";
    			this.btDéconnecter.Size = new System.Drawing.Size(136, 24);
    			this.btDéconnecter.TabIndex = 10;
    			this.btDéconnecter.Text = "Déconnecter";
    			this.btDéconnecter.Click += new System.EventHandler(this.btDéconnecter_Click);
    			// 
    			// btExécuterCommande
    			// 
    			this.btExécuterCommande.Location = new System.Drawing.Point(448, 152);
    			this.btExécuterCommande.Name = "btExécuterCommande";
    			this.btExécuterCommande.Size = new System.Drawing.Size(136, 24);
    			this.btExécuterCommande.TabIndex = 11;
    			this.btExécuterCommande.Text = "Exécuter Commande";
    			this.btExécuterCommande.Click += new System.EventHandler(this.btExécuterCommande_Click);
    			// 
    			// lbTexteRetour
    			// 
    			this.lbTexteRetour.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(128)), ((System.Byte)(0)));
    			this.lbTexteRetour.Location = new System.Drawing.Point(8, 192);
    			this.lbTexteRetour.Name = "lbTexteRetour";
    			this.lbTexteRetour.Size = new System.Drawing.Size(376, 136);
    			this.lbTexteRetour.TabIndex = 12;
    			this.lbTexteRetour.Text = "Texte Retour";
    			// 
    			// Form1
    			// 
    			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    			this.ClientSize = new System.Drawing.Size(632, 341);
    			this.Controls.Add(this.lbTexteRetour);
    			this.Controls.Add(this.btExécuterCommande);
    			this.Controls.Add(this.btDéconnecter);
    			this.Controls.Add(this.btConnecter);
    			this.Controls.Add(this.btConstruire);
    			this.Controls.Add(this.textBoxEntrerCommande);
    			this.Controls.Add(this.lbEntrerCommande);
    			this.Controls.Add(this.textBoxMotDePasse);
    			this.Controls.Add(this.label1);
    			this.Controls.Add(this.textBoxLogin);
    			this.Controls.Add(this.lbLogin);
    			this.Controls.Add(this.textBoxAdresseIp);
    			this.Controls.Add(this.lbAdresseIp);
    			this.Name = "Form1";
    			this.Text = "Form1";
    			this.ResumeLayout(false);
     
    		}
    		#endregion
     
    		/// <summary>
    		/// Point d'entrée principal de l'application.
    		/// </summary>
    		[STAThread]
    		static void Main() 
    		{
    			Application.Run(new Form1());
    		}
     
    		private void btConstruire_Click(object sender, System.EventArgs e)
    		{
     
    		}
            //pour le  bouton connecter
    		private void btConnecter_Click(object sender, System.EventArgs e)
    		{
     
    			//adresse Ip
    			string adresse_Ip=textBoxAdresseIp.Text; 
    			//le login 
    			string login= textBoxLogin.Text; 
    			//mot de passe 
    		    string mot_de_passe=textBoxMotDePasse.Text; 
     
     
    			//essayer : 
     
    			try
    			{
    				//Créer un nouvel objet CequipementReseaux avec en parametre
    				//l'adresse ip distante et l'identifiant.
    		    	EquipementRéseau  = new  CEquipementRéseau(adresse_Ip,login,mot_de_passe);
     
    				//appel la fonction Connecter de la class CequipementReseaux
    				lbTexteRetour.Text = EquipementRéseau.Connecter();
     
    			}
             catch (Exception f)
    				//affichage d'un message d'erreur si une exception est produite
    		{
    			lbTexteRetour.Text = (f.ToString());
     
    		}
    		}
     
     
    		private void btDéconnecter_Click(object sender, System.EventArgs e)
    		{
     
    		}
     
    		private void btExécuterCommande_Click(object sender, System.EventArgs e)
    		{
     
    		}
    	}
    }
    Le problème c'est que quand je compile j'ai une erreur:

    C:\Documents and Settings\Administrateur\Mes documents\TestTelnet\Form1.cs(255): Aucune surcharge pour la méthode 'CEquipementRéseau' ne prend d'arguments '3'
    Je ne vois pas ce que c'est ,
    Je cherche de mon coté mais si vous pouvez me dépanner
    Merci d'avance

  18. #18
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Octobre 2010
    Messages
    72
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2010
    Messages : 72
    Par défaut
    Ton constructeur prend 4 paramètres, et toi quand tu crées ton CEquipementRéseau tu lui en passes que 3, tu as oublié le NumeroDePort.
    Tu devrais faire par exemple :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    EquipementRéseau  = new CEquipementRéseau(adresse_Ip,login,mot_de_passe, 5001);
    Ou bien alors créer un constructeur qui ne prend que 3 paramètres (tu peux faire plusieurs constructeurs s'ils ont un nombre d'arguments différents ou des types d'arguments différents il me semble).

  19. #19
    Membre averti
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 37
    Par défaut
    Re bonjour
    Je reviens vous voir car à l'erreur précédente j'ai cette fois ci CequipementRéseau ne prend d'argument 4

    Que dois je faire ?

  20. #20
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Octobre 2010
    Messages
    72
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2010
    Messages : 72
    Par défaut
    Essaye d'enlever le mot-clé void devant ton constructeur...

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. Classe pour la création d'un graphe xy
    Par Bob dans le forum MFC
    Réponses: 24
    Dernier message: 03/12/2009, 17h20
  2. Réponses: 31
    Dernier message: 30/03/2006, 16h57
  3. Élaboration de classe
    Par il_a_ri dans le forum Langages de programmation
    Réponses: 6
    Dernier message: 16/01/2003, 14h22
  4. Variable d'une Classe Ancêtre
    Par Génie dans le forum Langage
    Réponses: 3
    Dernier message: 18/09/2002, 19h24
  5. Sortir un typedef d'une classe
    Par Theophil dans le forum C++Builder
    Réponses: 13
    Dernier message: 03/07/2002, 17h21

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo