I use a function that save string into a string array but visual 2012 show this error Object reference not set to an instance of an object.
this is my code :
public void ShowLinkList(ref TreeNode t, ref string[] Data, ref int i)
{
string str;
if (t!= null)
{
ShowLinkList(ref t.LeftChild, ref Data, ref i);
Data[i] = CreatStr(t.Parent.Word) + "," + CreatStr(t.LeftChild.Word )+ "," + CreatStr(t.RightChild.Word) + "," + CreatStr(t.Word);
i++;
ShowLinkList(ref t.RightChild, ref Data, ref i);
}
}
public string CreatStr(string str)
{
if (str == "")
{
return "__";
}
return str;
}
when t is null,the "if(t != null)" not allowed compiler to debug ,the CreatStr(string) convert a null string to "__" in output(windows form C#) this metode (ShowLinkList) saving t.parent.word & t.leftchild.word & t.rightchild.word & t.word in a string array please help me.thank you