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. C++ in C#

C++ in C#

Scheduled Pinned Locked Moved C#
questioncsharpc++
5 Posts 4 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.
  • O Offline
    O Offline
    Omar Gameel Salem
    wrote on last edited by
    #1

    hello i want to write C++ code within C# how can i do this? thanks in advance

    D S D O 4 Replies Last reply
    0
    • O Omar Gameel Salem

      hello i want to write C++ code within C# how can i do this? thanks in advance

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #2

      You can't. You can use C# to call into C++ assemblies though.

      Dave
      BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
      Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
      Why are you using VB6? Do you hate yourself? (Christian Graus)

      1 Reply Last reply
      0
      • O Omar Gameel Salem

        hello i want to write C++ code within C# how can i do this? thanks in advance

        S Offline
        S Offline
        Simon P Stevens
        wrote on last edited by
        #3

        You can't. You could write a dll in C++ and use it from C#, but you can't directly write c++ within a C# assembly.

        Simon

        1 Reply Last reply
        0
        • O Omar Gameel Salem

          hello i want to write C++ code within C# how can i do this? thanks in advance

          D Offline
          D Offline
          Dan Neely
          wrote on last edited by
          #4

          THe only way you can mix managed (like C#, VB.net, etc) and unmanaged (like normal c++) code in a single file is to use C++/CLI. This will let you use normal c++ and "c++.net". Unfortunately the resulting syntax is rather heavier than either normal C++ or C# code. As a result it's not generally recommended. Instead the preferred options are to either use p/invoke to call a c++ dll from within C# code, or to create a Managed COM object in C#, and use COM to call it from within C++ code.

          It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains. -- Pride and Prejudice and Zombies

          1 Reply Last reply
          0
          • O Omar Gameel Salem

            hello i want to write C++ code within C# how can i do this? thanks in advance

            O Offline
            O Offline
            Omar Gameel Salem
            wrote on last edited by
            #5

            Thanks davey, simon and dan you were extremely helpful ;) i think i'll use p/invoke thanks again

            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