ami7
Messages postés99Date d'inscriptiondimanche 8 août 2010StatutMembreDernière intervention29 juin 2011
-
30 mars 2011 à 01:35
ami7
Messages postés99Date d'inscriptiondimanche 8 août 2010StatutMembreDernière intervention29 juin 2011
-
30 mars 2011 à 11:39
bonjour
j'ai message d'erreur suivant : Object reference not set to an instance of an object
et indique un trait jaune au niveau de la méthode " dessiner_Sommet(Sommet s)"
mon code c'est :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public List<Sommet> les_Sommets = new List<Sommet>();
public List Les_Aretes = new List();
public Graphics g;
public Sommet s = new Sommet();
public Graphe G = new Graphe();
public Arete A = new Arete();
private int rayon_cercle = 18;
public Form1()
{
InitializeComponent();
les_Sommets = G.les_Som;
}
//retrouver un Sommet par son nom
public Sommet trouver_Sommet(string nom)
{
foreach (Sommet s in les_Sommets)
if (s.nom == nom)
return s;
return null;
}
g.DrawString(s.nom, new Font("Microsoft Sans Serif", 15), new SolidBrush(Color.Black), new PointF((float)s.x + rayon_cercle, (float)s.y));
}
private bool ajouter_Sommet(Sommet nouvelle)
{
if (nouvelle.nom != string.Empty)
{
foreach (Sommet s in les_Sommets)
{
if ((s.x nouvelle.x && s.y nouvelle.y) || s.nom == nouvelle.nom)
{
MessageBox.Show("Nouveau Sommet Invalide\n Verifiez Que le Nom ou les Coordonnees n'existent pas deja", "Du calme", MessageBoxButtons.OK);
return false;
}
}
les_Sommets.Add(nouvelle);
}
else
{
MessageBox.Show("Vous devez entrer le Nom du Sommet", "Du calme", MessageBoxButtons.OK);
return false;
}
return true;
}
}
}
A voir également:
Object reference not set to an instance of an object.
Object reference not set to an instance of an object c# - Meilleures réponses