|
-
Sep 23rd, 2007, 06:57 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] [2.0] string pointers?
Well I need to pass the location of a string in memory to a function. In C++ you would just do &string but what do you do in C#? I have tried many things and nothing seems to work.
-
Sep 23rd, 2007, 07:40 PM
#2
Re: [2.0] string pointers?
Just on C# you don't need to use Pointers and you don't need to delete them because of garbage collection. But you can use pointers. You declare them like so...
-
Sep 23rd, 2007, 08:54 PM
#3
Thread Starter
Frenzied Member
Re: [2.0] string pointers?
 Originally Posted by Hell-Lord
Just on C# you don't need to use Pointers and you don't need to delete them because of garbage collection. But you can use pointers. You declare them like so...
Ya but I need to call a function that uses the strings location.
-
Sep 23rd, 2007, 10:33 PM
#4
Re: [2.0] string pointers?
You can also use the Marshal.StringToBSTR to get an IntPtr to an unmanaged string that you can then pass to your function. BSTRToString will convert back again if needed. Make sure you read the documentation first if you choose to use these methods.
-
Sep 24th, 2007, 06:08 AM
#5
Re: [2.0] string pointers?
Are you talking about a DLL function? Just use a StringBuilder, they are automatically marchalled as char*.
(you'll have to alter your DllImport statement to change char* to Stringbuilder in your C# code).
I don't live here any more.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|