The problem is that array.ToString() isn't overridden by the language. Instead, you probably want to use another function, like string.Concat:
GenerateCode(parentNode1, string.Concat(array));
The result you were getting is because the default implementation of ToString() (object.ToString(), that is) prints out type information.
Although if you do have control over the GenerateCode method, I would strongly suggest modifying its parameter type to accept an IEnumerable<T> or array. Converting to a string, unless necessary, will lose some major benefits of strong-typing. I would make that conversion in the method, not before it. That will allow you to change the implementation later on without worrying about what parameters you pass.
Furthermore, I'd be tempted to write your values to a StringBuilder rather than the console, since that will be way more useful in a majority of real-world applications.
public static void GenerateCode(StringBuilder builder, Node parentNode, IEnumerable<int> values)
{
if (parentNode != null)
{
GenerateCode(builder, parentNode.leftChild, Concat(values, 0));
if (parentNode.leftChild == null && parentNode.rightChild == null)
builder.AppendLine(string.Format("{0}{{{1}}}", parentNode.data, string.Concat(values));
GenerateCode(builder, parentNode.rightChild, Concat(values, 1));
}
}
private static IEnumerable<T> Concat(IEnumerable<T> coll, T obj)
{
foreach (var v in coll)
yield return v;
yield return obj;
}
Then you can call it, of course, like this.
StringBuilder builder = new StringBuilder();
GenerateCode(builder, parentNode1, array);
Console.Write(builder.ToString());