Question:
How Is C# Different from Java?
Kaydell
2009-02-27 22:19:03 UTC
I know the Java programming language. I've heard that C# is much like Java. How are they different?
Five answers:
Sun
2009-02-27 22:25:53 UTC
C# is similiar to java but different because it relys fully on the .NET framework to function. Java on the othr hand actually has to run in it's own environment which kinda slows it down.



C# is also relatively new but is forcefully taking over the market, java has been in awhile but I think in a few years it'll fade away because microsoft is so actively pushing the .NET framework.



Last but not least, Java is developed by sun microsystems, while C# is developed by Microsoft.
victor m
2009-03-01 23:17:58 UTC
Java and C# more or less match with each other.Java is influeced by C++ whereas C# is enhaced version of C++. C# derives from C/C++ with modernization and type safety- to adapt the changes in environment and to implement advances in the art of programming.

In Java the return type ofmain() is void whereas in C#, We are not restricted only to void we can also also have int.

In Java pointers does not exist and was not designed to be compatible with any other languge. Although the default for C# code is safe mode , we can declare classes or method to be unsage This enable us to use pointers , structs andstatically allocated arrays.Both the safe mode and unsafe code run in the managed space , which implies no marshalling is incurred when calling unsafe code from safe code.

In Java the main(), if there are no parameters required we still need to incle the command line parameters array. This is not the case with C# we can declare Main() as

public static void Main(){...}

Although Java supports constructors, it doesn't have destructors. Whereas in C# we have destructors to release all the expensive resources even though we have garbage collector, which does the same - isn't invoked immediately after the variable goes out of scope, but only at certain intervals or memory conditions.



In Java it is not possible to declare unsigned integers whereas in C# POS type system i.e., intended to support the complete implementation of a wide range of programming language makes us impossible to declare unsigned integers.
Alex Ryder
2009-02-27 22:29:21 UTC
Well dear friend C# is .Net framework language the difference is that C# have namespace in place of packages, Java doesn't support multiple inheritence but C# support multiple inheritence. Although it contain more visibility levels like "public" "private" "protected" "internal" "protected internal" but java support only public private and protected.



Rest are same as Java.



Have a nice day
Balki
2009-02-27 22:31:48 UTC
Java works in different platform but the specific JRE(Java Run time environment) should be installed for each OS.



But,



C# in .Net Platform which supports mutli-platform and many languages (C#, C++, C, ASP, VB, VC++ etc.) So, C# can easily interconnect with the other languages.



It is not so easy to code in Java.
livermore
2016-10-04 07:12:40 UTC
Java and C# form of extra healthful with each diverse.Java is influeced by way of C++ on a similar time as C# is enhaced version of C++. C# derives from C/C++ with modernization and form take care of- to adapt the ameliorations in environment and to enforce advances in the artwork of programming. In Java the bypass lower back form ofmain() is void on a similar time as in C#, we don't look constrained maximum useful to void we are able to have the skill to additionally even have int. In Java rules does not exist and grew to become into as quickly as not designed to be suitable with another languge. even with the incontrovertible fact that the default for C# code is unhazardous mode , we are able to have the skill to declare categories or equipment to be unsage This enable us to to hire rules , structs andstatically disbursed arrays.the two the unhazardous mode and unsafe code run in the controlled abode , which shows no marshalling is incurred on a similar time as calling unsafe code from unhazardous code. In Java the main impressive(), if there at the instant are no parameters required we nonetheless have have been given to incle the command line parameters array. that may not the case with C# we are able to have the skill to declare considerable() as public static void considerable(){...} even with the incontrovertible fact that Java facilitates constructors, it would not have destructors. while in C# we've got destructors to liberate the completed luxury sources besides the fact that we've got rubbish collector, which does the equivalent - isn't invoked right away after the variable is going out of scope, even nonetheless maximum useful at particular sessions or memory circumstances. In Java it is not conceivable to declare unsigned integers on a similar time as in C# POS form technique i.e., meant to help the completed implementation of a huge form of programming language makes us staggering to declare unsigned integers.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...