站内搜索: 请输入搜索关键词
当前页面: 图书首页 > NET For Java Developers Migrating To C#

NET For Java Developers Migrating To C#

[ directory ] Previous Section Next Section

Overview of Chapters

Although you are welcome to consult any random chapter as a reference for understanding its C# concept, we recommend reading the chapters in order. In that way, you won't get bogged down by syntax and construct questions when it comes to discussing the more esoteric APIs. Following is a brief description of each chapter.

Chapter 1, The .NET Framework, is an overview of the various components of the .NET framework. Readers itching to code can skip this chapter.

Chapter 2, Starting with C#, explores the proverbial Hello World program梖irst without using the Visual Studio .NET integrated development environment (IDE), and then using the IDE. We briefly explain the components of the IDE. Knowledge of the IDE is important if you are to develop large-scale enterprise applications. However, you don't need to be well versed in the IDE to understand the language concepts.

Chapter 3, C# and Java: What Is the Difference?, lists the features of C# and compares them to equivalent features in Java. This chapter makes for good reading for those who want to quickly know how C# differs from Java.

Chapter 4, Writing Objects, gets down to the business end of OOP: writing objects. Java programming is all about writing classes.

Chapter 5, Understanding Inheritance and Polymorphism, looks at the cornerstones of any OOP language. Both Java and C# use a single-root class hierarchy and have polymorphism. As a Java programmer you have probably been pampered by Java's always turned-on, automatic virtual dispatching. The C# approach is to have virtual dispatching turned off by default. What does that mean to you as a Java programmer? This chapter illustrates some C# pitfalls that Java programmers might fall into if they are not careful.

Chapter 6, Implementing Interfaces, explains that both Java and C# allow a class to implement multiple interfaces. We discuss several aspects of a C# interface.

Chapter 7, Data Types, explores the elements that make a programming language. C# provides a lot more data types and constructs than Java does. You should read this chapter if you want to exploit C#-specific constructs and not end up writing everything as a class in C#.

Chapter 8, Operators, covers a fairly mundane, but important, topic. You may be surprised to learn that C# supports operator overloading.

Chapter 9, Essential Control Flow, discusses control flow statements such as if-then-else, switch, for, foreach, and many more. C# is a very expressive language that contains built-in optimizations of some constructs. You will learn that C# allows strings in switch statements, along with many other surprising details.

Chapter 10, Programming with Exceptions, treats something that used to be an option in C++ and is now a major part of the Java language. Fortunately, C# and Java both agree on making exception handling a core part of the language. Unfortunately, there is no throws clause in C#. So how do you know which exceptions are thrown by a method you call? As a Java programmer you might find C#'s lenient exception handling both a blessing and a curse.

Chapter 11, Working with Arrays, explains this fundamental data structure, which is found in any programming language. C# goes a step further than most languages by having a special class for arrays.

Chapter 12, Processing Strings, deals with one of the most ubiquitous classes of Java, which also happens to be commonplace in C#. This chapter discusses the fundamental concepts of string equality, interning, and optimizations.

Chapter 13, Formatting Numbers, Strings, and Dates, discusses the C# equivalent of the java.text.* package.

Chapter 14, Using Collections, explains how both Java and C# collections let you build an automobile without reinventing the wheel. Unfortunately, the C# collection library is currently no match for what Java has to offer.

Chapter 15, Working with the C# I/O API, discusses I/O streams, files, directories, and serialization. C# makes a distinction between a file and a directory, and it gives you several ways to make a class serializable.

Chapter 16, Thread Programming, shows you how C# has simplified threading. You can finally close threads in C#, and it gives you a system-supplied thread pool梐nd this means no more scrambling for third-party implementations. You can have reader-writer locks on resources, something the JDK does not provide out of the box. C# also gives you four different ways to write multithreaded classes. Many more surprises unfold in this chapter.

Chapter 17, Using C# Properties, Indexers, and Attributes, may bring back memories long forgotten for Java programmers who once were Visual Basic programmers. Properties reduce code clutter by eliminating getter and setter calls. Indexers let you treat collections as arrays, and attributes let you tinker with the metadata of your code. None of these features is supported in Java.

Chapter 18, Delegates and Event Programming, explains how function pointers, abandoned in Java, are back in C# as delegates. Here's another example of how C# goes out of its way to not model every concept or construct as a class.

Chapter 19, Accessing Databases, deals with a capability that is part of the core .NET API. A unique C# data structure is the RowSet object, which is basically an in-memory representation of an RDBMS table or view. This chapter discusses some of the routine database operations that you will want to execute.

Chapter 20, Processing XML, reveals that XML processing, which has finally made it into the core API in Java 1.4, is a first-class concept in C#. You get built-in support for XML, XSL translation, and XPath in C#'s core libraries.

Chapter 21, GUI Programming in C#, is brimming with practical advice for GUI builders. The Java Swing library has become the preferred API for building client-side Java GUI applications. The Swing library consists of classes modeled after the MVC (model view controller) pattern. Although very modular, Swing can be tedious to work with because the JDK does not ship with a GUI designer. This makes it a chore to design rich, interactive screens because everything must be coded by hand. Only recently have third-party Java IDEs become available to simplify Swing programming. In contrast, the .NET Windows Forms library is reminiscent of Visual Basic drag-and-drop Forms, with event-driven code associated with the controls on the form. If you have the Visual Studio .NET handy, then GUI programming in C# is reduced to drag-and-drop and adding event-based code. The Visual Studio .NET Forms Designer is a welcome change for languishing Swing programmers.

Chapter 22, Reflection, explains that reflective capabilities go hand in hand with managed code and type-safe data types. Reflection allows you to probe the metadata behind the various language constructs. Both C# and Java provide a great set of reflection API classes. But C#'s reflection emit feature takes the cake because it lets you dynamically generate and run MSIL code.

Chapter 23, Assemblies, Application Configuration, and Process Management, argues that packaging is everything. This is true even for computer applications. An improperly packaged and deployed application either will not work or will give you runtime headaches. C# assemblies let you deploy complex applications as one unit that can be versioned. C# also provides several deep hooks into Windows operating system process management. Read all about assemblies and processes in this chapter.

    [ directory ] Previous Section Next Section