3 Mar 2004 mrd   » (Master)

C#: So I needed a reference to a string object, so that some XML could call the String.Concat() method to concatenate 2 strings in XML.

This will be trivial I think - inside my XML parsing engine we create a new keyword, making available a string object:

case "STRING":
    currObj = new String();
    break;

Ahh, but there's no constructor that takes zero arguments. Looking through the API docs, there's a version that takes a char *, a char[], a string etc for a total of 8 variants - but no default zero param constructor! None of these are really suitable for this particular purpose (this is managed code, no pointers for you!). Why no standard default constructor of String()? Java has always had that available - another trap for people writing in both C# and Java.

The simple work around was:

case "STRING":
    String foo = "";
    currObj = foo;
    break;

so I could then do something like this in XML:

<ACTION NAME="CallMethod" UID="202" REFERENCE="{SetProp Application, SomeLabel, {STRING.Concat(XMLVAR1, XMLVAR2)})}"/>

Not a big deal, but another of those simple differences between these two languages (really their supplied library APIs) that just needn't be there. The level of compatibility at a source code level could be better.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!