Introduction

Targeted audience

This book is meant for Java developers who want to learn the C# language as quickly as possible. Basic familiarity with the Java language syntax and semantics, and an academic foundation in object-oriented programming are assumed. (Don't worry, you don't have to be an expert! And you don't need to read this book with a Java reference companion.)

Software prerequisites

In order to try out the C# codes in this book, you will need a copy of .NET SDK[2] or VS .NET from Microsoft. The .NET SDK and .NET Framework will be installed when you install VS .NET. If you are not using VS .NET, you may want to get a color-coded text editor instead of using Notepad for coding purposes.

[2] Can be downloaded from http://msdn.microsoft.com/netframework.

What this book covers

The fundamental concepts of how .NET works are covered in Part 1. The rest of the book focuses on the C# language itself, with relevant comparisons between C# and the Java programming language.

What is covered:

  • fundamental .NET concepts, especially those pertaining to how C# works;

  • C# syntax and semantics;

  • important .NET BCLs used for multi-threading, file I/O, reflection operations, and some useful collection classes.

What is not covered:

  • use of other .NET BCLs;

  • use of C# for web services, web forms (ASP .NET), graphics (GDI+), COM interoperability, database access (ADO .NET);

  • other .NET issues such as .NET security and remoting.

Typographic conventions used

TypefaceMeaningExample
AaBbCc123Names of commands, files, and directories

interfaces, classes, methods, and variables

programming language keywords
Edit the file Test.cs

Invoke the method doSomething

Create an instance of the Human class
AaBcCc123Book titles, new words or terms, or words to be emphasizedYou must invoke this method before instantiating the class

Codes

At the time of writing, a fully working implementation of C# in VS .NET has just been released. The C# codes shown in this book have been compiled and tested using the command line C# compiler (csc.exe) of the first final release version of VS .NET.

Errata discoveries

Being a realistic technologist, I expect errors - typos and even the technical variety - in my book. It would help if you can send me an e-mail so that I can make the necessary corrections in future reprints. Useful and constructive comments will be acknowledged in future editions. Expensive chocolate, fine wines, and generous praise are also welcome. You can find the latest erratum list at www.mokhengngee.per.sg/book.

Trademarks

".NET", "Visual Studio .NET", "Visual C# .NET", "Visual Basic .NET" are trademarks of Microsoft Corporation. "Java" is a trademark of Sun Microsystems.

Structure of the book

This book is divided into seven major parts.

Part 1: Introducing .NET and C#

This part gives a brief overview of what .NET and C# are all about without going into the specifics. There is a brief explanation of .NET technologies, and a good conceptual foundation is provided about how .NET applications work. You write your first Hello World in Part 1.

Part 2: Classes, methods, and other OO stuff

This part discusses how C# handles classes, namespaces, methods, constructors, and variables. Object-oriented related issues are covered here.

Part 3: Types, operators, and flow control

The language semantics and syntax of C# are almost identical with Java's. This part is written such that you can skim through it relatively quickly to appreciate the differences.

Part 4: Core topics

Topics covered in this part include arrays, event handling, exception handling, reflection, multi-threading, the collection classes, and file I/O. These are major topics which often warrant a huge separate chapter in other C# books. This book does not go through the basic ideas but does emphasize how to perform these operations in C#. The chapters in this part assume prior knowledge about exceptions, reflection, and multi-threading.

Part 5: Convenience features

Convenience features[3] are C# features which are good to have but not essential. Basically they help increase programmer productivity by providing shortcuts for the normal ways of doing things. Topics covered include C# properties, indexes, operator overloading, and user-defined conversions. These will all be new topics to a Java developer. Convenience features do not increase the power of a language, but just make it more convenient for a good programmer to use it. Like a double-edged sword, convenience features steepen the learning curve significantly, but give the programmer more elegant ways to accomplish tasks.

[3] I think I am the originator of the term 'convenience features'. I haven't read any literature using that term for C# properties, indexes, and the like.

Part 6: C#-specific features

This part describes features found in C# which have no equivalents in Java. Topics include C# preprocessor directives, attributes, structures, enums, and unsafe coding. Care has been taken to write this part clearly, so that it is simple to understand yet comprehensive.

Part 7: Appendices

There are six appendices. Here you will find the full list of C# keywords, and their closest equivalents in Java. I have also included C# coding conventions (a good starting point even before coding commences), a useful summary on how to write XML documentation (which resembles the Javadoc comments) and a short write-up on .NET assemblies. The many (necessary) abbreviations are also defined here - as opposed to the missable first-time definitions sometimes given in the text.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.178.9