You are previewing From Java to C#: A Developer's Guide.
O'Reilly logo
From Java to C#: A Developer's Guide

Book Description

The fastest way for Java developers to pick up C# and .Net - by leveraging on what they already know in Java to learn the new language. 

  • Allows a Java developer to pick up C# as quickly as possible by highlighting the similarities and differences between the two languages.

  • Extensive detailed coverage of the new features in C# not found in Java.

  • A useful introduction to the .NET platform and how the new architecture works.  It's important for a C# developer to know what happens behind the scenes.

  • User Level:



    All intermediate Java developers.


    C# is a new programming language which is promoted by Microsoft as the successor to C++.  C# together with Visual Basic .NET are the two most popular programming languages .NET  developers use to write applications targeted at the .NET platform.

    Author Biography:

    Mok Heng Ngee is an experienced software developer and architect who has been involved in numerous large-scale software enterprise projects based on the Java 2 Platform, Enterprise Edition (J2EE).  Mok has writes for Computer Times and has been invited to speak at the official launch of Visual Studio .NET in Singapore.  He has been accorded MVP (Most Valuable Professional) status by Microsoft  Asia.

    Table of Contents

    1. Copyright
    2. About the author
    3. Preface
    4. Introduction
    5. Acknowledgments
    6. Introducing .NET and C#
      1. Introducing .NET
        1. Evolution: from COM to .NET
        2. What exactly is .NET?
        3. Multiple .NET programming languages and VS.NET
        4. Intermediate language
        5. The .NET Common Language Runtime
        6. Competing in parallel with Java technologies
        7. Common language infrastructure
        8. Other .NET-related technologies
        9. Unsafe codes and real time programs
        10. Porting .NET to other operating systems
      2. Introducing C#
        1. Potent combo of Java and C++
      3. JUMP to .NET and J#
        1. Java Language Conversion Assistant
        2. The J# language
      4. Hello C#!
        1. How to compile and run the code examples in this book
        2. Some .NET specifics
        3. Disassembling an assembly file
    7. Classes, methods and other OO stuff
      1. Getting started
        1. Basic class structure
        2. Basic console I/O
        3. C# namespaces (Java packages)
      2. Class issues
        1. Class modifiers
        2. Class members
        3. Creating an object with the new operator
        4. Looking at System.Object
        5. Class inheritance
        6. Implementing interfaces
        7. Sealed classes (Java final classes)
        8. Abstract classes
        9. Nested classes (Java inner classes)
      3. Method issues
        1. Method modifiers
        2. Method basics
        3. Instance constructors
        4. Static constructors (Java static initializers)
        5. Destructors
        6. Constructor initializers and constructor chaining
        7. Method overloading
        8. Passing variable numbers of parameters into C# methods
        9. Abstract methods
        10. Method overriding using the virtual and override Modifiers
        11. Method hiding with the new keyword
        12. Static methods
        13. Sealed methods (Java final methods)
      4. Miscellaneous issues
        1. Access modifiers
        2. Static members
        3. C# constants and read-only fields (Java final variables)
        4. Volatile fields
    8. Types, operators, and flow control
      1. C# types
        1. Pointer types
        2. Reference types
        3. Value types
        4. Unsigned types in C#
        5. The decimal type
        6. The char type
        7. The string type and string literals
        8. All types are objects
        9. Casting for reference types
        10. Casting for value types
        11. Common typing with other .NET languages
      2. C# operators
        1. Operators and their precedence in C#
        2. Operator overloading
        3. typeof operator
        4. checked and unchecked operators and statements
        5. The == operator
        6. The is operator (Java's instanceof operator)
        7. The as operator
      3. Iteration and flow control
        1. Looping with the while, do, for, continue and break keywords
        2. Conditional statements using the if and else keywords
        3. Looping with the foreach keyword
        4. Conditional statements with the switch andcase keywords
        5. Flow control with the break and continue keywords
        6. Flow control with the goto keyword
    9. Core topics
      1. Arrays
        1. One-dimensional arrays
        2. Multi-dimensional arrays: rectangular arrays
        3. Multi-dimensional arrays: jagged arrays
        4. Mixing jagged and rectangular arrays
        5. Using the System.Array class
      2. Exception handling
        1. Exception examples
        2. C# exception hierarchy
        3. Examining System.Exception
        4. Inner exceptions
        5. Catching generic exceptions
      3. C# delegates
        1. What are delegates?
        2. A first delegate example
        3. Combining delegates
        4. Removing delegates
        5. Exception throwing in delegates
        6. Passing method parameters by reference in delegates
      4. C# events
        1. Generic event model
        2. What are C# events?
        3. A full example
        4. Another full example
      5. Reflection and dynamic method invocation
        1. Retrieving the type of an instance
        2. Retrieving the type from a name of a class
        3. Retrieving methods from a type
        4. Retrieving modules from an assembly
        5. Dynamically invoking methods in late bound objects
        6. Creating new types during runtime
      6. Multi-threaded programming
        1. Multi-threading
        2. Thread states and multi-threading in C#
        3. Thread synchronization
        4. Threading guidelines
      7. File I/O
        1. Copying, moving, and deleting files
        2. Copying, moving, and deleting directories
        3. Reading from or writing to a binary file
        4. Reading from and writing to text files
      8. C# collection classes
        1. ArrayList
        2. BitArray
        3. Hashtable
        4. Queue
        5. SortedList
        6. Stack
    10. Convenience features
      1. C# properties
        1. Properties as a replacement for accessor and mutator methods
        2. Having only either the get or set section
        3. Inheritance of properties
      2. C# indexes
        1. Overloading indexers
        2. Wrong use of indexers
      3. Operator overloading
        1. Explaining operator overloading
        2. Operator overloading proper
        3. Another example of operator overloading
      4. User-defined conversions/casts
        1. The implicit and explicit keywords
        2. Syntax of user-defined conversion method declarations
    11. C#-specific features
      1. C# preprocessor directives
        1. Conditional compilation With #define, #undef, #if and #endif
        2. #else and #elif
        3. The /define compiler option and #undef
        4. #warning and #error
        5. #region and #endregion
      2. Using enums
        1. Specifying different int values for enum elements
      3. C# structures
        1. First look at structs
        2. Differences between a struct and a class
        3. Why use a struct?
      4. C# attributes
        1. First look at attributes
        2. Standard attributes
      5. Writing custom attributes
        1. An attribute class
        2. Another custom attribute example
        3. Naming attribute classes and attribute specifications
        4. Custom attributes in depth
        5. The AttributeUsage attribute
      6. Writing unsafe codes
        1. Definitions
        2. Comparing Java and C#/.NET
        3. Introducing pointers
        4. Using the unsafe keyword
        5. Declaring pointers
        6. Using the & address-of operator
        7. Using the * Indirection operator
        8. Passing pointers to methods
        9. Using the -> member access operator
        10. Using the sizeof operator
        11. Pointer casting
        12. Pointer arithmetic
        13. Using the fixed keyword
        14. A further example
    12. Appendices
      1. Keywords in C#
      2. Comparing Java and C# keywords
      3. C# coding conventions
        1. General naming conventions
        2. Naming C# events
        3. Naming C# enums
        4. Naming C# interfaces
        5. Naming C# properties
        6. Naming namespaces
        7. Language interoperability issues
      4. XML documentation
      5. C# command line tools
      6. About .NET assemblies
        1. What is an assembly?
        2. Shared assemblies and the GAC
        3. What is DLL hell?
        4. Creating DLL assemblies using csc.exe
        5. Compiling to modules
        6. Referencing an external module during compilation of an assembly
      7. Abbreviations used in this book