Visual Studio: C # programming language for Java Developers (1)

Source: Internet
Author: User
Tags exception handling garbage collection naming convention visual studio

This article discusses the similarities and differences between Java and C # in order to let Java developers master some of the knowledge involved when migrating to. NET. The main similarities between Java and C # are:

java and C # are all derived from C + +, and there are some features of C + +.
java byte code is passed by called Ja VA virtual Machine (JVM) application execution. Similarly, compiled C # programs are executed by the common language runtime (Common Language Runtime, CLR).
except for some minor differences, in C # Exception handling is very similar to Java. C # uses Try...catch constructs to handle run-time errors (also known as exceptions), which is exactly the same as in Java. The System.Exception class is the base class for all C # exception classes.
as Java, C # is a strong class Type check programming language. The compiler is able to detect type errors that may cause problems at run time.
as Java, C # provides automatic garbage collection, which allows programmers to avoid tracking allocated resources.
java and C # both support a single relay Commitment and multiple interface implementations.

Now let's take a look at the important differences covered in this article:

The C # language introduces new language constructs, such as foreach, indexers, properties, delegates, operator overloads, and other language constructs. We'll discuss these constructs in more detail later in this article.

Source File Conventions

We need to know that the two languages differ in the file naming conventions and structures of the source program:

File naming

The naming convention for files that contain C # classes is somewhat different from Java. First, in Java, the extension of all source files is. java. Each source file contains a top-level public class declaration, and the class name must match the file name. In other words, a class named Customer with a public scope declaration must be defined in a source file that has a name Customer.java.

The C # source code is represented by the. cs extension. Unlike Java, a source file can contain multiple top-level public class declarations, and file names do not need to match any class names.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.