... Friday, October 13 , 2006 2 :11 PM CHAPTER ■■■ Introducing C+ +/CLI T his chapter introduces the C+ +/CLI language extensions to C+ + and shows you the classic “Hello, World” example in C+ +/CLI You’ll ... Hogenson_705- 2C0 1. fm Page Friday, October 13 , 2006 2 :11 PM CHAPTER ■ INTRODUCING C+ +/CLI class N { }; ref class R { }; N* n = new N; // standard C+ + pointer to an object R^ r = gcnew R; // C+ +/CLI handle ... the term classic C+ + Hogenson_705- 2C0 1. fm Page Friday, October 13 , 2006 2 :11 PM CHAPTER ■ INTRODUCING C+ +/CLI The /clr Compiler Option If you use Visual C+ + 2005, you have to let the compiler...
... 213 10 .12 .1 Class loading and initialization . 215 11 Structs 217 11 .1 Struct declarations 217 11 .1. 1 Struct modifiers . 217 11 .1. 2 Interfaces ... representing a character of classes Mn or Mcdecimal-digitcharacter: A Unicode character of the class Nd A unicode-character-escape-sequence representing a character of the class Nd underscore-character: ... 10 .10 .5 Private constructors 212 10 .10 .6 Optional constructor parameters . 212 10 .11 Destructors 212 10 .12 Static constructors 213 10 .12 .1...
... difficult 9…… calculations can be done very quickly on computers 10 …… NOW, CHECK! A The world’s first electronic computer was built 1 …… by the university of Pennsylvania in 19 46 However, computers ... Pronounce these words by your self September November primary chemistry algebra engineer December October physical politics statistics volunteer careful cinema computing academic secondary entertain ... However, computers sold commercially 2… … for the first time in the 19 50s Much progress on computers are making since 19 50 computers are …… now much smaller and more powerful and they can be bought...
... 208 11 Structs 211 11 .1 Struct declarations 211 11 .1. 1 Struct modifiers 211 11 .1. 2 Interfaces 211 11 .1. 3 Struct body ... 16 1 9.5 Type declarations 16 1 10 Classes 16 3 10 .1 Class declarations 16 3 10 .1. 1 Class modifiers 16 3 10 .1. 1 .1 Abstract classes ... or Nl combining-character: A Unicode character of classes Mn or Mc A unicode-character-escape-sequence representing a character of classes Mn or Mc decimal-digitcharacter: A Unicode character...
... the C# language 11 Contents Inheritance 10 0 Points 10 0 Persons 10 2 12 he class Object 10 9 13 Abstract classes 11 3 Abstract points 11 3 Loan 11 5 Interfaces 12 2 Points again 12 2 Money 12 3 Static members ... bookboon.com C# Introduction to programming and the C# language Contents Contents Foreword 11 Part Introduction to C# 13 Introduction 14 Hello World 14 Basic program architecture 18 Print a book 18 ... types 16 4 he class Set 16 6 21 Exception handling 17 4 22 Comments 18 1 23 Extension methods 18 7 Part Collection classes 19 0 24 List 19 2 A List of strings 19 2 Enter sale of products 19 4 Stack...
... the three commands cc -c x .c cc -c y .c cc -c y .c would compile x .c, y .c, and z .c and create object files x.o, y.o, and z.o Then, the three object files could be linked together using cc -o myprog ... separate source files, x .c, y .c, and z .c We could compile all three of them, and link them together, all at once, with the command cc -o myprog x .c y .c z .c Alternatively, we could compile them ... which work similarly For example, the Microsoft C compiler comes with a CL (``compile and link'') command, which works almost the same as Unix cc You can compile and link in one step: cl hello.c...
... exception when this code is executed Example: private dynamic TrungBinh(dynamic s1, dynamic s2) { return (s1 + s2) / 2; } private void button1_Click(object sender, EventArgs e) { dynamic tb = TrungBinh(2, ... Extension methods: Example public static class myString { public static bool EqualsIgnoreCase ( this string s1, string s2 ) { return s1.Equals(s2, StringComparison.OrdinalIgnoreCase); } } string s = ... Slide Dynamic type dynamic myDynamicVar; Regardless of the value that myDynamicVar actually contains, this code will compile If the requested member does not exist, you will get an exception...
... semicolon (;) 11 Basic concepts in C# (cont.) • Namespace (p. 51) • Namespaces are used as a means of categorizing items • Within a namespace, you can declare: • • • • • • another namespace class ... class interface struct enum delegate • C# is case sensitive 12 Console Application (try it out p .18 ) • Basic Console Application structure using System; using System.Collections.Generic; using System.Linq; ... is C# ? • C# is one of the languages included in the NET Framework – C# is an object-oriented programming language • Applications you can write with C# – – – – Windows applications Web applications...
... representing a character of classes Mn or Mcdecimal-digitcharacter: A Unicode character of the class Nd A unicode-character-escape-sequence representing a character of the class Nd underscore-character: ... unicode-character-escape-sequence representing a character of classes Lu, Ll, Lt, Lm, Lo, or Nl combining-character: A Unicode character of classes Mn or Mc A unicode-character-escape-sequence ... identifier-part-character identifier-part-character: letter-character combining-character decimal-digit-character underscore-character letter-character: A Unicode character of classes Lu, Ll,...
... type declaration depends on the form of the type declaration For instance, class declarations can contain declarations for instance constructors ( 10 .10 ), destructors ( 10 .11 ), static constructors ... private declared accessibility Struct members cannot have protected or protected internal declared accessibility • Interface members implicitly have public declared accessibility No access modifiers ... derived class can access a protected constructor of a base class in a constructor-initializer ( 10 .10 .1) In the example public class A { protected int x; } static void F(A a, B b) { a.x = 1; //...
... conversions are classified as standard implicit conversions: • Identity conversions (§6 .1. 1) • Implicit numeric conversions (§6 .1. 2) • Implicit reference conversions (§6 .1. 4) Copyright Microsoft Corporation ... Explicit reference conversions • Explicit interface conversions • Unboxing conversions • User-defined explicit conversions Explicit conversions can occur in cast expressions (§7.6.8) The explicit ... integral type, the processing depends on the overflow checking context (§7.5 .13 ) in which the conversion takes place: • In a checked context, the conversion succeeds if the source argument is within...
... struct Color { public static readonly Color White = new Color( ); public static readonly Color Black = new Color( ); public Color Complement() { } } class A { public Color Color; // Field Color ... overflow checking context 11 0 Copyright Microsoft Corporation 19 99-2000 All Rights Reserved Chapter Expressions The overflow checking context can also be controlled through the checked and unchecked ... example Copyright Microsoft Corporation 19 99-2000 All Rights Reserved 11 1 C# LANGUAGE REFERENCE class Test { const int x = 10 00000; const int y = 10 00000; static int F() { return checked(x *...
... switch-block switch-block: { switch-sectionsopt } switch-sections: switch-section switch-sections switch-section switch-section: switch-labels statement-list switch-labels: switch-label switch-labels ... x; x = 1; int y; int z; z = x * 2; } 8.5.2 Local constant declarati ons A local-constant-declaration declares one or more local constants local-constant-declaration: const type constant-declarators ... constant-declarators constant-declarators: constant-declarator constant-declarators , constant-declarator constant-declarator: identifier = constant-expression The type of a local-constant-declaration specifies...