From Java to C# : A Developer's Guide

From Java to C# : A Developer's Guide

  • ただいまウェブストアではご注文を受け付けておりません。 ⇒古書を探す
  • 製本 Paperback:紙装版/ペーパーバック版/ページ数 480 p.
  • 言語 ENG
  • 商品コード 9780321136220
  • DDC分類 005.133

Full 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: Intermediate. Audience: All intermediate Java developers. Technology: 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.

Contents

About the author xiii Preface xv Introduction xvii Acknowledgments xxi Part 1 Introducing .NET and C# 1 1 Introducing .NET 3 1.1 Evolution: from COM to .NET 3 1.2 What exactly is .NET? 5 1.3 Multiple .NET programming languages and VS .NET 6 1.4 Intermediate language 8 1.5 The .NET common language runtime 9 1.6 Competing in parallel with Java technologies 12 1.7 Common language infrastructure 14 1.8 Other .NET-related technologies 19 1.9 Unsafe codes and real time programs 22 1.10 Porting .NET to other operating systems 23 2 Introducing C# 25 2.1 Potent combo of Java and C!! 26 3 JUMP to .NET and J# 30 3.1 Java Language Conversion Assistant 30 3.2 The J# language 30 4 Hello C#! 34 4.1 How to compile and run the code examples in this book 34 4.2 Some .NET specifics 36 4.3 Disassembling an assembly file 36 Part 2 Classes, methods, and other OO stuff 39 5 Getting started 41 5.1 Basic class structure 41 5.2 Basic console I_O 45 5.3 C# namespaces (Java packages) 50 Contents 6 Class issues 56 6.1 Class modifiers 56 6.2 Class members 56 6.3 Creating an object with the new operator 60 6.4 Looking at System.Object 61 6.5 Class inheritance 63 6.6 Implementing interfaces 65 6.7 Sealed classes (Java final classes) 73 6.8 Abstract classes 73 6.9 Nested classes (Java inner classes) 74 7 Method issues 78 7.1 Method modifiers 78 7.2 Method basics 79 7.3 Instance constructors 84 7.4 Static constructors (Java static initializers) 85 7.5 Destructors 87 7.6 Constructor initializers and constructor chaining 88 7.7 Method overloading 91 7.8 Passing variable numbers of parameters into C# methods 91 7.9 Abstract methods 94 7.10 Method overriding using the virtual and override modifiers 96 7.11 Method hiding with the new keyword 101 7.12 Static methods 105 7.13 Sealed methods (Java final methods) 107 8 Miscellaneous issues 109 8.1 Access modifiers 109 8.2 Static members 114 8.3 C# constants and read-only fields (Java final variables) 116 8.4 Volatile fields 119 Part 3 Types, operators, and flow control 123 9 C# types 125 9.1 Pointer types 126 9.2 Reference types 126 9.3 Value types 129 9.4 Unsigned types in C# 132 9.5 The decimal type 133 9.6 The char type 133 9.7 The string type and string literals 134 9.8 All types are objects 136 9.9 Casting for reference types 139 9.10 Casting for value types 140 9.11 Common typing with other .NET languages 142 10 C# operators 144 10.1 Operators and their precedence in C# 144 10.2 Operator overloading 149 10.3 typeof operator 150 10.4 checked and unchecked operators and statements 153 10.5 The # # operator 159 10.6 The is operator (Java's instanceof operator) 162 10.7 The as operator 164 11 Iteration and flow control 167 11.1 Looping with the while, do, for, continue and break keywords 167 11.2 Conditional statements using the if and else keywords 170 11.3 Looping with the foreach keyword 171 11.4 Conditional statements with the switch and case keywords 173 11.5 Flow control with the break and continue keywords 174 11.6 Flow control with the goto keyword 175 Part 4 Core topics 181 12 Arrays 183 12.1 One-dimensional arrays 184 12.2 Multi-dimensional arrays: rectangular arrays 185 12.3 Multi-dimensional arrays: jagged arrays 187 12.4 Mixing jagged and rectangular arrays 189 12.5 Using the System.Array class 190 13 Exception handling 193 13.1 Exception examples 193 13.2 C# exception hierarchy 204 13.3 Examining System.Exception 206 13.4 Inner exceptions 208 13.5 Catching generic exceptions 210 14 C# delegates 212 14.1 What are delegates? 212 14.2 A first delegate example 215 14.3 Combining delegates 216 14.4 Removing delegates 219 14.5 Exception throwing in delegates 221 14.6 Passing method parameters by reference in delegates 221 15 C# events 223 15.1 Generic event model 223 15.2 What are C# events? 225 15.3 A full example 227 15.4 Another full example 230 16 Reflection and dynamic method invocation 236 16.1 Retrieving the type of an instance 239 16.2 Retrieving the type from a name of a class 240 16.3 Retrieving methods from a type 241 16.4 Retrieving modules from an assembly 243 16.5 Dynamically invoking methods in late bound objects 244 16.6 Creating new types during runtime 245 17 Multi-threaded programming 248 17.1 Multi-threading 248 17.2 Thread states and multi-threading in C# 250 17.3 Thread synchronization 261 17.4 Threading guidelines 270 18 File I_O 272 18.1 Copying, moving, and deleting files 272 18.2 Copying, moving, and deleting directories 276 18.3 Reading from or writing to binary files 276 18.4 Reading from and writing to text files 281 19 C# collection classes 284 19.1 ArrayList 284 19.2 BitArray 287 19.3 Hashtable 291 19.4 Queue 294 19.5 SortedList 296 19.6 Stack 298 Part 5 Convenience features 301 20 C# properties 303 20.1 Properties as a replacement for accessor and mutator methods 304 20.2 Having only either the get or set section 306 20.3 Inheritance of properties 307 21 C# indexes 309 21.1 Overloading indexers 310 21.2 Wrong use of indexers 312 22 Operator overloading 314 22.1 Explaining operator overloading 314 22.2 Operator overloading proper 316 22.3 Another example of operator overloading 318 23 User-defined conversions_casts 321 23.1 The implicit and explicit keywords 323 23.2 Syntax of user-defined conversion method declarations 324 Part 6 C#-specific features 325 24 C# preprocessor directives 327 24.1 Conditional compilation with #define, #undef, #if and #endif 327 24.2 #else and #elif 330 24.3 The /define compiler option and #undef 332 24.4 #warning and #error 333 24.5 #region and #endregion 334 25 Using enums 335 25.1 Specifying different int values for enum elements 336 26 C# structures 339 26.1 First look at structs 339 26.2 Differences between a struct and a class 341 26.3 Why use a struct? 349 27 C# attributes 351 27.1 First look at attributes 351 27.2 Standard attributes 354 28 Writing custom attributes 359 28.1 An attribute class 359 28.2 Another custom attribute example 362 28.3 Naming attribute classes and attribute specifications 365 28.4 Custom attributes in depth 366 28.5 The AttributeUsage attribute 370 29 Writing unsafe codes 376 29.1 Definitions 376 29.2 Comparing Java and C#_.NET 377 29.3 Introducing pointers 380 29.4 Using the unsafe keyword 381 29.5 Declaring pointers 382 29.6 Using the & address-of operator 384 29.7 Using the * indirection operator 386 29.8 Passing pointers to methods 390 29.9 Using the -> member access operator 391 29.10 Using the sizeof operator 392 29.11 Pointer casting 393 CONTENTS xi 29.12 Pointer arithmetic 394 29.13 Using the fixed keyword 398 29.14 A further example 400 Part 7 Appendices 403 Appendix A Keywords in C# 405 Appendix B Comparing Java and C# keywords 408 Appendix C C# coding conventions 411 Appendix D XML documentation 417 Appendix E C# command line tools 428 Appendix F About .NET assemblies 430 F.1 What is an assembly? 430 F.2 Shared assemblies and the GAC 431 F.3 What is DLL hell? 432 F.4 Creating DLL assemblies using csc.exe 433 F.5 Compiling to modules 434 F.6 Referencing an external module during compilation of an assembly 435 Appendix G Abbreviations used in this book 437 Index 439 FROM JAVA TO C# xii