Call C# code in C
I want to call c# code in c is it possible if so give me simple example to multiply by calling c# multiply function from c
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jan 10, 2013, 5:20 AM
The only obvious problem I can see is that 'List' is used without a type parameter if this is the same List as the framework class, System.Collections.Generic.List
I'd have thought it needed to be List
VulpesPosted Nov 30, 2012, 8:44 AM
No worries, it's not something you'd be likely to know unless (like me) you've spent years inter-operating with unmanaged code.
@ sridevi pc
If the console is closing before you've time to read the output, I'd try inserting the highlighted lines towards the end of the main() function in test.c:
If that's the case then you'll need to do more to the IL than just adding an .export directive (ilasm 2.0 does most of this for you). I've highlighted all the lines that need inserting:
sridevi pcPosted Nov 30, 2012, 8:32 AM
VulpesPosted Nov 30, 2012, 7:48 AM
If that's the case, then it's OK to remove 'static' before 'class' but you must leave it in for the Multiply method itself.
Vithal WadjePosted Nov 30, 2012, 7:46 AM
sridevi pcPosted Nov 30, 2012, 7:43 AM
sridevi pcPosted Nov 30, 2012, 7:41 AM
sridevi pcPosted Nov 30, 2012, 7:40 AM
Thanks for the reply
when i try to do step to am getting errorr message "
multiply.cs(3,21): error CS0106: The modifier 'static' is not valid for this
item "
csc /t:library multiply.cs
should i make Multiply function as non staticVulpesPosted Nov 30, 2012, 7:25 AM
Vithal WadjePosted Nov 30, 2012, 6:58 AM