Actually, you are trying to work with cstrings in your first example, and your code pretty much shows you just didn't understand how cstrings work. For cstrings you normally use output parameters, because otherwise you'd have to reserve memory on the heap which the user would have to free later on.