I thank you in advance for your responses.
Cheers,
Alex
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Jul 14, 2010, 5:09 PM
One big surprise is that both C# and Java have non-deterministic destruction. They both use garbage collection which does not act on objects immediately. I am not familiar with the details of what Java has to offer, but C# has the IDisposable interface. It was added to the language during beta testing, so it was not part of the origial design of the language. Or probably it is .Net instead of just C#. In C++ we know when the destructor will execute but in C# we don't know when an object is destroyed unless the Destroy member of IDisposable is called and sometimes it is difficult to get that to work.
Something else I have had difficult with is the Using statement. Note that there are multiple Using statements; one use is similar to the using of a namespace in C++. Another use of Using is to wrap code in try/catch. I don't like that kind of Using but I suspect (I am not sure) that one reason it is best to use Using is that it helps ensure that the Dispose method is called.
Unlike C#, there are big differences between structs and classes in C#. It will help you to study up on that. In C# there are value types and reference types, and it can be confusing which is which. I think it would help a lot to understand that structs are nearly always value types and classes are always reference types. Value types are allocated on the stack and reference types are allocated in the heap.
Another big surprise is that C# arrays cannot be increased or decreased in size. I think that might not be totallly true but if you want something like a std::vector then use an ArrayList or a similar collection. Note that collections in the system.collections namespace are not type-safe in the sense that you can use various object types in them but collections in the system.collections.generic namespace are type-safe in the manner that collections in the C++ std namespace (templated objects) are.
Also, we must call the Flush method of output streams explicitly; it is not called automatically from the Close method.
Roy SPosted Jul 14, 2010, 3:56 AM
Mahesh ChandPosted Jul 13, 2010, 8:48 PM
http://www.c-sharpcorner.com/Beginners/
Welcome and good luck!