# Marshaling char \*\* from dll in c#?

**URL:** <https://boards.straightdope.com/t/marshaling-char-from-dll-in-c/353511>\
**Category:** Factual Questions\
**Created:** [April 20, 2006, 7:14pm UTC](https://boards.straightdope.com/t/marshaling-char-from-dll-in-c/353511 "2006-04-20T19:14:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Khadaji](https://avatars.discourse-cdn.com/v4/letter/k/9e8a1a/32.png) [@Khadaji](https://boards.straightdope.com/u/Khadaji)\
**Post date:** [April 20, 2006, 7:14pm UTC](https://boards.straightdope.com/t/marshaling-char-from-dll-in-c/353511/1 "2006-04-20T19:14:11Z")

</div>

I have a third party DLL. One function (properly exported) is declared:

int GetObects(char \*\* str, int len)  
{  
}

Anyone know how to declare that in c#?

(I can’t recall the proper syntax for cdecl right now, so assume that it has been properly declared and exported and focus on the char\*\* part)

---

<div class="post-metadata">

**Author:** ![Khadaji](https://avatars.discourse-cdn.com/v4/letter/k/9e8a1a/32.png) [@Khadaji](https://boards.straightdope.com/u/Khadaji)\
**Post date:** [April 21, 2006, 2:47am UTC](https://boards.straightdope.com/t/marshaling-char-from-dll-in-c/353511/2 "2006-04-21T02:47:36Z")

</div>

OK, it seems to be as simple as:

[DllImport(“YourDllName.dll”)]  
public static extern int GetObjects(ref string data, int length);

// To call it…

string theData = string.Empty;

// Pad the string just in case  
theData = theData.PadLeft(101,’ ');

GetObjects(ref theData, 100);

I haven’t fully tested it yet, but so far that is what I’m coming up with.
