Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4607508
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:42:47+00:00 2026-05-22T00:42:47+00:00

It is a simple sample. CodeDLL.cpp File: extern C { __declspec(dllexport) int __cdecl SimulateGameDLL

  • 0

It is a simple sample.

CodeDLL.cpp File:

extern "C" {
    __declspec(dllexport) int __cdecl SimulateGameDLL (int a, int b) {
              return a*b; // Calculation in native code
      }
}

GameSharp.cs File:

static class GameSharp
{
    public static class UnsafeNativeMethods
    {
        const string _dllLocation = "CoreDLL.dll";

        [DllImport(_dllLocation)]
        public static extern int SimulateGameDLL(int a, int b);
    }
}

or

static class GameSharp
{
    public static class GameSharpClass
    {       
        public static int SimulateGameDLL(int a, int b) {
             return a*b; //Calculation in managed code
        }
    }
}

The first one : I have a dll file that written in c++ native code and i try to call function in it in the managed code.(wrapper)

In the second one i have convert it to Managed Code.
My Code is not as simple as this.Which One is better Convert My c++ native code to Managed Or Call it form Managed Code.
Which one is faster? Why?

If this is not clear, please tell me i will discuss it more.don’t vote it to close before tell me. 🙂 thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T00:42:48+00:00Added an answer on May 22, 2026 at 12:42 am

    I believe when it comes to performance in .NET there isn’t a noticeable difference between managed and unmanaged code.

    I would convert your unmanaged code to managed if its all running on .NET anyway.

    I just think you shouldn’t be worried about a performance bottleneck at this level. If your doing game development, you should be worried about performance when it comes to networking and graphics (use shaders).

    EDIT:

    http://msdn.microsoft.com/en-us/library/bb677124.aspx

    “Maximum speed of execution. The managed layer adds around 10% overhead to the program.” (for windows mobile)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A simple question, but could someone provide sample code as to how would someone
Looking for some sample code (C#) for a simple thread pool implementation. I found
This simple sample code demonstrates the problem. I create an ArrayBlockingQueue , and a
I have some very simple sample code like this: $.ajax({ url: 'demo2.htm', success: function(loadeddata){
I have some very simple sample code like this: $.ajax({ url: 'demo2.htm', success: function(loadeddata){
I have a simple iphone app that's based on the CrashLanding sample app. So
I'm developing a simple appplication to play WAV files using PlaySound, with this code:
public partial class Form1 : Form { [DllImport(coredll.dll)] static extern int SetWindowLong(IntPtr hWnd, int
Take a look on this simple sample: <input type="button" value="btn1" id="btn1" /> <input type="button"
I need to setup NACHOS java version in Linux and run some simple sample

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.