Click here to Skip to main content
15,921,530 members
Home / Discussions / C#
   

C#

 
GeneralRe: RegEx - Allowing Spaces Pin
Dave Kreskowiak8-Feb-06 16:36
mveDave Kreskowiak8-Feb-06 16:36 
GeneralRe: RegEx - Allowing Spaces Pin
Expert Coming8-Feb-06 19:19
Expert Coming8-Feb-06 19:19 
QuestionRich Text Box and Hyperlinks Pin
DELETEUSER8-Feb-06 11:32
DELETEUSER8-Feb-06 11:32 
AnswerRe: Rich Text Box and Hyperlinks Pin
DigitalKing8-Feb-06 13:07
DigitalKing8-Feb-06 13:07 
QuestionConverting and things to their html codes Pin
eggie58-Feb-06 11:05
eggie58-Feb-06 11:05 
AnswerRe: Converting and things to their html codes Pin
Edbert P8-Feb-06 11:28
Edbert P8-Feb-06 11:28 
QuestionDevExpress ASPxGrid question Pin
golfaddict8-Feb-06 9:51
golfaddict8-Feb-06 9:51 
QuestionPassing string from C++ code to C# Pin
Roman Muntyanu8-Feb-06 9:47
Roman Muntyanu8-Feb-06 9:47 
Hi all,

I am passing string from C++ to C# but not sure which way is more correct. Here it is:
First approach:
CDAnetCSharpHooks::PassString( )
{
char str[] = "String to pass";
DotNetObject *obj = new DotNetObject();
obj->UseStringInDotNet( str );
}

Second approach:
CDAnetCSharpHooks::PassString( )
{
char str[] = "String to pass";
CString temp(str);
System::String * dotNetStr = new System::String( temp);
DotNetObject *obj = new DotNetObject();
obj->UseStringInDotNet( dotNetStr );
}

C# method
public void UseStringInDotNet( String str )
{
// create new thread and use string in it
}

UseStringInDotNet() is creating new thread and that is why PassString() will finish its work before UseStringInDotNet() finishes its own.
Basically first approach is working, but sometimes on the .NET side I have some unpredictable behaviour in memory. I am wondering if that memory for str buffer is cleared before C# get its work done. In this respect will be the second approach more safe ?

Thank you very much in advance for any suggestions

Roman
AnswerRe: Passing string from C++ code to C# Pin
leppie8-Feb-06 10:57
leppie8-Feb-06 10:57 
Questioncompile .dll into .exe file Pin
sergej8-Feb-06 6:22
sergej8-Feb-06 6:22 
AnswerRe: compile .dll into .exe file Pin
Judah Gabriel Himango8-Feb-06 7:27
sponsorJudah Gabriel Himango8-Feb-06 7:27 
QuestionTreeView Send Message Error Pin
sameerhanda8-Feb-06 5:36
sameerhanda8-Feb-06 5:36 
GeneralRe: TreeView Send Message Error Pin
DigitalKing8-Feb-06 9:20
DigitalKing8-Feb-06 9:20 
Questionimages uploading and displaying Pin
Net-Programer-and-developer8-Feb-06 4:35
Net-Programer-and-developer8-Feb-06 4:35 
AnswerRe: images uploading and displaying Pin
Ingo8-Feb-06 5:28
Ingo8-Feb-06 5:28 
QuestionSymbolic Integration & Automatic Differentiation Pin
Naveed Shoaib8-Feb-06 4:23
Naveed Shoaib8-Feb-06 4:23 
AnswerRe: Symbolic Integration & Automatic Differentiation Pin
Ingo8-Feb-06 5:25
Ingo8-Feb-06 5:25 
QuestionUser Control Change Data Pin
tadhg888-Feb-06 4:19
tadhg888-Feb-06 4:19 
QuestionUsing the XML.Serialize Pin
NewbieDude8-Feb-06 3:46
NewbieDude8-Feb-06 3:46 
QuestionUnset ReadOnly? (Basic BitWise Question!) Pin
MartinSmith8-Feb-06 3:37
MartinSmith8-Feb-06 3:37 
AnswerRe: Unset ReadOnly? (Basic BitWise Question!) Pin
User 66588-Feb-06 3:47
User 66588-Feb-06 3:47 
GeneralRe: Unset ReadOnly? (Basic BitWise Question!) Pin
MartinSmith8-Feb-06 3:52
MartinSmith8-Feb-06 3:52 
QuestionHome directory Pin
TonyLinde8-Feb-06 3:22
TonyLinde8-Feb-06 3:22 
AnswerRe: Home directory Pin
User 66588-Feb-06 3:45
User 66588-Feb-06 3:45 
GeneralRe: Home directory Pin
TonyLinde8-Feb-06 3:59
TonyLinde8-Feb-06 3:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.