Results 1 to 6 of 6

Thread: C# syntax compared to C++

  1. #1
    Lively Member
    Join Date
    Sep 11
    Posts
    65

    C# syntax compared to C++

    hi,
    Im just starting out with C#, and is it the syntax very similar to C++? I have been doing a little C++ over the summer and i am finding the syntax of C# similar to C++ like instance the If statements, ETC. However what i found is different is like creating arrays and stuff.

  2. #2
    Fanatic Member
    Join Date
    Jan 06
    Posts
    515

    Re: C# syntax compared to C++

    Similar, but C++ is a monster (not in a good way) compared to C#:
    1. Compare C++ function pointers with C# delegates.
    2. C++ #define macros can quickly reduce C++ code to undecipherable rubbish.
    3. C++ array syntax only works in some situations - in others you have to resort to pointers. Also, you can't have an array as a function return type in C++.
    4. C++ is unmanaged - no garbage collection.

    You need a lot of experience in C++ to produce even the simplest applications.

    C++/CLI addresses some of the issues, such as garbage collection, but almost no one uses it and the syntax for arrays and properties are cumbersome compared to C#.
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com
    Instant C# - VB to C# Converter
    Instant VB - C# to VB Converter

  3. #3
    New Member
    Join Date
    Aug 12
    Posts
    1

    Re: C# syntax compared to C++

    C# syntax is very much easier than C++. You can easily write code in C#.C# programs run very fast and also compile.


    immobilier international

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 02
    Posts
    21,653

    Re: C# syntax compared to C++

    Because C# is loosely based on C/C++ and was designed to attract C/C++ developers to .NET it has a lot of similarities. I'd even go so far as to suggest that C# has as much in common with C/C++ as VB.NET has in common with VB Classic (VB 6 and earlier). The C language part of it itself is the same, just like the VB language is the same... the changes come with the framework and the other additions. That and the fact that C# is a managed language while C++ isn't. Generally speaking that means C++ is less forgiving and will let you make unsafe calls into places you may or may not want to. C# is less forgiving and will attempt to prevent you from shooting yourself in the foot, if it can.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    *Proof positive that searching the forums does work: View Thread *
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *
    * Use Offensive Programming, not Defensive Programming. * On Error Resume Next is error ignoring, not error handling(tm).
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN

  5. #5
    Fanatic Member KGComputers's Avatar
    Join Date
    Dec 05
    Location
    www.vbforums.com
    Posts
    550

    Re: C# syntax compared to C++

    Hi,

    [However what i found is different is like creating arrays and stuff.]

    I'm referring to your array statement.
    If you have done some Visual C++.NET as I did before, then creating list/arrays is somehow similar.

    Have a look at MSDN.
    http://msdn.microsoft.com/en-us/libr...h2ey19.aspx#Y0

    Greg

  6. #6
    Fanatic Member x-ice's Avatar
    Join Date
    Mar 04
    Location
    UK
    Posts
    671

    Re: C# syntax compared to C++

    Nobody has mentioned the similarities between C# and Java.

    http://en.wikipedia.org/wiki/Compari...Sharp_and_Java

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •