120 likes | 195 Views
C#. A brief overview by Jack Senechal and Bryan Powell. Origins. Developed in the late 90’s by Anders Hejlsberg at Microsoft, as part of MS’s .NET strategy Similar to Java Descended from C and C++ Modern, Object Oriented language. Language Features. Strongly Typed
E N D
C# A brief overview by Jack Senechal and Bryan Powell
Origins • Developed in the late 90’s by Anders Hejlsberg at Microsoft, as part of MS’s .NET strategy • Similar to Java • Descended from C and C++ • Modern, Object Oriented language
Language Features • Strongly Typed • Has automatic garbage collection • native support for interfaces and interface inheritance
Target audience • All around language, covering more of the spectrum of possible applications than Java. • Meant to be a balance between control and productivity.
Cross-Platform Compatibility • Microsoft designed C# with cross-platform compatibility in mind. Any platform with the .NET framework implemented (i.e., Windows) can run programs written in C# and compiled to MSIL. • However, other compilers are becoming available (MCS, the Ximian C# compiler, compiles C# code to CIL, an intermediate language that can be run using their JIT compiler on a multitude of platforms).
Language Translation • “The Common Language Runtime (CLR) manages the execution of .NET code. When you compile a C# program, the output of the compiler is not executable code. Instead, it is a file that contains a special type of pseudocode called Microsoft Intermediate Language (MSIL). . . . The JIT compiler converts MSIL into native code on a demand basis as each part of your program is needed.”
Flow Control Conditional Statements · ternary operator ([ test ] ? statement_1 : statement_2;) ·if statement ·if-else statement ·switch statement Looping Statements ·for ·while ·do-while Jump Statements ·goto statement ·break statement ·continue statement ·return statement
Parameter Passing • 4 types of parameter passing: • value (default – pass by value) • ref (pass by reference) • out (the caller passes only the address of the object, which the callee must instantiate with some new value—the old value of the object is discarded and ignored, and it is illegal to try and reference it within the callee) • params (collects parameters from the caller and creates a local array of these elements—the number of parameters need not be specified).
Scoping • class A • { • int i = 0; • void F() { • i = 1; // Error, use precedes declaration • int i; • i = 2; • } • } • No scoping operators
Interesting Datatypes • Uses both [][] and [,] notations for multi-dimensional arrays. The [][] is called a jagged array, and is considered an array of arrays, whereas [,] is simply a single two-dimensional array. Still not sure what the difference is functionally, if any. • Decimal – 28-29 decimal places of accuracy.
Errata • Library support – significant support from Microsoft as part of the .NET framework. • Delegates – C#’s way of dealing with pointers to methods
Resources • http://www.c-sharpcorner.com/ • http://msdn.microsoft.com/vstudio/techinfo/articles/upgrade/Csharpintro.asp • http://msdn.microsoft.com/vcsharp/ • http://www.csharphelp.com/ • http://genamics.com/developer/csharp_comparative.htm • http://www.csharp-station.com/Tutorial.aspx • http://www.microsoft.com/mspress/books/sampchap/5490.asp • http://www.cs.unca.edu/~powellba/example.cs • http://www.cs.unca.edu/~powellba/example.exe