Exforsys

Online Training

C# compared to C & C++

This is a discussion on C# compared to C & C++ within the C Sharp forums, part of the Programming Talk category; Compared to C and C++, the language is restricted or enhanced in a number of ways, here's some of ...


Go Back   Exforsys > Programming Talk > C Sharp

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-24-2006, 10:06 PM
Senior Member
 
Join Date: May 2006
Posts: 99
klorpet is on a distinguished road
C# compared to C & C++

Compared to C and C++, the language is restricted or enhanced in a number of ways, here's some of them (feel free to add to this list):
  • True support for pointers. However pointers can only be used within unsafe scopes, and only programs with appropriate permissions can execute code marked as unsafe. Most object access is done through safe references, which cannot be made invalid, and most arithmetic is checked for overflow. An unsafe pointer can be made to not only value-types, but to subclasses of System.Object as well. Also safe code can be written that uses a pointer (System.IntPtr).
  • Managed memory cannot be explicitly freed, but instead is garbage collected when no more references to the memory exist. (Objects that reference unmanaged resources, such as an HBRUSH, can be instructed to release those resources through the standard IDisposable interface, which provides a pattern for deterministic deallocation of resources.)
  • Multiple inheritance is prohibited (although a class can implement any number of interfaces). This was a design decision by the language's lead architect (Anders Hejlsberg) to avoid complication, avoid 'dependency hell,' and simplify architectural requirements throughout CLI (Common Language Infrastructure).
  • C# is more typesafe than C++. The only implicit conversions by default are safe conversions, such as widening of integers and conversion from a derived type to a base type (and this is enforced at compile-time and, indirectly, during JIT). There are no implicit conversions between booleans and integers and between enumeration members and integers, and any user-defined implicit conversion must be explicitly marked as such, unlike C++'s copy constructors.
  • Syntax for array declaration is different ("int[] a = new int[5];" instead of "int a[5];").
  • Enumeration members are placed in their own namespace.
  • C# 1.0 lacks templates, however, C# 2.0 provides generics.
  • Properties are available which results in syntax that resembles C++ member field access, similar to VB.
  • Full type reflection and discovery is available.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-02-2006, 06:43 AM
Member
 
Join Date: Apr 2006
Posts: 98
Angela is on a distinguished road
Good post. C# is derived from C++ and Java. The main programming codes are like C++ and also has the style of Java programming. So it is easier to program in C# than in C++.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-05-2006, 03:09 AM
Senior Member
 
Join Date: May 2006
Posts: 99
klorpet is on a distinguished road
Thanks Angela
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-07-2006, 11:46 PM
Junior Member
 
Join Date: Jun 2006
Posts: 1
nguyenanhduc is on a distinguished road
Post how to write website for mobile phone

Help me !
I want to write the website for mobile but i don't know "How to write ?" Can you help me ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 06-13-2006, 07:36 PM
Senior Member
 
Join Date: May 2006
Posts: 99
klorpet is on a distinguished road
You should post this in the project request area so that more people see it and can offer assistance. You might want to include timeline and any other details.

Good luck.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
PostgreSQL : MySQL and PostgreSQL Compared techguru Other DBs 0 08-27-2005 05:25 AM


All times are GMT -4. The time now is 04:24 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.