{"id":15,"date":"2016-02-10T16:23:46","date_gmt":"2016-02-10T16:23:46","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=15"},"modified":"2022-02-17T06:24:15","modified_gmt":"2022-02-17T06:24:15","slug":"c-for-c-programmers","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/c-sharp\/c-specifications\/c-for-c-programmers","title":{"rendered":"C# for C++ programmers"},"content":{"rendered":"<h4>\n\tGood Resources<br \/>\n<\/h4>\n<p>\n\t<a href=\"http:\/\/www.andymcm.com\/csharpfaq.htm\" target=\"_blank\" rel=\"noopener\">C# FAQ for C++ programmers<\/a>\n<\/p>\n<h4>\n\tSome Key Differences<br \/>\n<\/h4>\n<h5>\n\tClasses and structs<br \/>\n<\/h5>\n<p>\n\tClasses and structs are almost the same in C++ &#8211; this is not true for C#. &nbsp;In C#, structs are value types (instances stored directly on the stack, or inline within heap-based objects), whereas classes are reference types (instances stored on the heap, accessed indirectly via a reference). Also structs cannot inherit from structs or classes, though they can implement interfaces. Structs cannot have destructors. A C# struct is much more like a C struct than a C++ struct.\n<\/p>\n<h5>\n\tMemory types<br \/>\n<\/h5>\n<p>\n\tChars and strings in .NET are 16-bit (Unicode\/UTF-16), not 8-bit like C++\n<\/p>\n<h5>\n\t#include<br \/>\n<\/h5>\n<p>\n\tThere is no &#39;#include&#39; statement &#8211; use &quot;using&quot; instead. &nbsp;See <a href=\"https:\/\/ibex.tech\/csharp\/c\/include\/include-in-c\">here<\/a>.\n<\/p>\n<h5>\n\t#define<br \/>\n<\/h5>\n<p>\n\tThere is no &#39;#define&#39;&nbsp;statement &#8211; use const instead. &nbsp;See&nbsp;<a href=\"https:\/\/ibex.tech\/csharp\/c\/define\/define\">here<\/a>.\n<\/p>\n<h5>\n\tHeader Files (*.h)<br \/>\n<\/h5>\n<p>\n\tNope, not used in C#. &nbsp;See <a href=\"https:\/\/ibex.tech\/csharp\/c\/header-files\/header-files\">here<\/a>.\n<\/p>\n<h4>\n\tUsing C++ code with C#<br \/>\n<\/h4>\n<p>\n\tWhere existing C++ code must be used with a new application, the existing code can be wrapped using C++\/CLI to allow it to interop with C#.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Good Resources C# FAQ for C++ programmers Some Key Differences Classes and structs Classes and structs are almost the same in C++ &#8211; this is not true for C#. &nbsp;In C#, structs are value types (instances stored directly on the stack, or inline within heap-based objects), whereas classes are reference types (instances stored on the [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-15","post","type-post","status-publish","format-standard","hentry","category-c-specifications"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/15","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":6,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"predecessor-version":[{"id":523,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/15\/revisions\/523"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}