Click here to Skip to main content
15,885,056 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
Good day all I create an object and then use a method on that object but I think I have an error in my code can anyone assist me

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Pastel.Evolution;
using DD.Library;

public partial class Default4 : System.Web.UI.Page
{


    private Lib.cPastel
          objPastel;

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        objPastel.CreateGRV(648337); getting Null reference exception here  void method only takes an int as an parameter

    }
Posted
Comments
mrDivan 30-May-14 3:35am    
Thank you So much after hours of coding sometimes it helps to have an outside view because we miss the small things

you haven't create any instance of objPastel,
C#
//create new instance 
objPastel = new Lib.cPastel();
//then call the method 
objPastel.CreateGRV(648337);

if you creating this instance of cPastel somewhere else in your program and asigning to objPastel , then you better check for null like below
C#
if(objPastel!=null)
{
   objPastel.CreateGRV(648337);
}
 
Share this answer
 
v2
Thank you So much after hours of coding sometimes it helps to have an outside view because we miss the small things
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900