Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to add C++ code in CSharp Programming

how to add C++ code in CSharp Programming

Scheduled Pinned Locked Moved C#
csharpc++helptutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    phijophlip
    wrote on last edited by
    #1

    Hi Can anyone tell me how to embbeded C++ code in CSharp in application? Can anyone help me in this matter. Hoping for a favorable reply From Phijo Mathew Philip. :)

    E N 2 Replies Last reply
    0
    • P phijophlip

      Hi Can anyone tell me how to embbeded C++ code in CSharp in application? Can anyone help me in this matter. Hoping for a favorable reply From Phijo Mathew Philip. :)

      E Offline
      E Offline
      erfi
      wrote on last edited by
      #2

      what do you mean? if you want to use pointers in c# you must write the code in a unsafe block like this :

      unsafe
      {
      int *i;
      //...
      }

      but in first you must set the option of your vs.net to use unsafe blocks in Compiler Option . i hope this be useful.

      1 Reply Last reply
      0
      • P phijophlip

        Hi Can anyone tell me how to embbeded C++ code in CSharp in application? Can anyone help me in this matter. Hoping for a favorable reply From Phijo Mathew Philip. :)

        N Offline
        N Offline
        Nader Elshehabi
        wrote on last edited by
        #3

        Hello C++ is called unmanaged code, while C# is managed. They are two different languages despite the similarity in names. C++ compile to machine language while C# compile to IL language then to machine language at runtime. That's among other differences. Whatever you want to do in C++ -excpet very few cases like inline assembly-, you still cane do with C#. For example: 1- You can make P/Invoke callse to old C++ libraries and Windows API functions 2- You can use pointers as Erfi showed you 3- You can include a C++ dll project in your solution and reference to it. Write your C++ code in that library. 4- you can reference to COM objects written in C++.

        Regards:rose:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups