object reference not set to an instance of object exception coming at runtime.
Posted
by amby
on Stack Overflow
See other posts from Stack Overflow
or by amby
Published on 2010-04-08T19:22:16Z
Indexed on
2010/04/08
19:23 UTC
Read the original article
Hit count: 441
c#
Hi, I am getting this error at runtime: object reference not set to an instance of object
my question is that am i using stringbuilder array correctly here. Because I am new in C#. and i think its the problem with my stringbuilder array. Below is the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using System.Web.Script.Serialization;
using System.Web.Script.Services;
using System.Collections;
public partial class Testing : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static string SendMessage()
{
try
{
al2c00.ldap ws = new al2c00.ldap();
Hashtable htPeople = new Hashtable();
//DataTable dt = ws.GetEmployeeDetailsBy_NTID("650FA25C-9561-430B-B757-835D043EA5E5", "john");
StringBuilder[] empDetails = new StringBuilder[100];
string num = "ambreen";
empDetails[0].Append("amby");
num = empDetails[0].ToString();
htPeople.Add("bellempposreport", num);
JavaScriptSerializer jss = new JavaScriptSerializer();
string output = jss.Serialize(htPeople);
return output;
}
catch(Exception ex)
{
return ex.Message + "-" + ex.StackTrace;
}
}
}
please reply me what i am doing wrong here.
© Stack Overflow or respective owner