Presentation is loading. Please wait.

Presentation is loading. Please wait.

Overview CNS 3260 C#.NET Software Development. 2.NET Framework Began in 2000 Developed in three years (2000 to 2003) Operating System Hardware.NET Framework.

Similar presentations


Presentation on theme: "Overview CNS 3260 C#.NET Software Development. 2.NET Framework Began in 2000 Developed in three years (2000 to 2003) Operating System Hardware.NET Framework."— Presentation transcript:

1 Overview CNS 3260 C#.NET Software Development

2 2.NET Framework Began in 2000 Developed in three years (2000 to 2003) Operating System Hardware.NET Framework Runtime (CLR).Net Application.Net DLL.Net Web Service

3 3 Source Code  Output C# source code CSC MSIL CLR CSC – C# Compiler MSIL – Microsoft Intermidiate Language or IL CLR - Common Language Runtime

4 4 Common Language Runtime (CLR) Similar to the Java Virtual Machine All.NET languages compile down to Intermediate Language (MSIL or just IL) CLR Runs the IL language IL compiled “Just In Time” (JIT) Compiled code reflects the current platform’s assembly language

5 5 JIT JIT code compiled at runtime and loaded into RAM Slow? Use ngen.exe If more RAM is needed, least used code is dropped If that code is needed again, it is recompiled and reloaded Buy more RAM Once code is loaded it stays in RAM and is reused as much as needed with no interpretation (conversion) overhead

6 6 MSIL ka IL Code Example class MainClass { public static void Main() { int i = 7; int j = i + 8; Console.WriteLine(j); } Translates to .method public hidebysig static void Main() cil managed {.entrypoint // Code size 13 (0xd).maxstack 2.locals init (int32 V_0, int32 V_1) IL_0000: ldc.i4.7 IL_0001: stloc.0 IL_0002: ldloc.0 IL_0003: ldc.i4.8 IL_0004: add IL_0005: stloc.1 IL_0006: ldloc.1 IL_0007: call void [mscorlib]System.Console::WriteLine(int32 ) IL_000c: ret } // end of method MainClass::Main A nice tool: http://www.remotesoft.com/dotexplorer/

7 7 CLR Power.NET Languages can inherit, pass variables, throw exceptions seamlessly to each other IL in-process of standardization by ECMA (European Computer Manufacturers Association) Automatic garbage collection Be sure to nullify references. Be sure to Dispose classes requiring disposing (covered later)

8 8 Common Type System (CTS) All.NET languages use the same types All.NET languages, creating the same type of code, can interact with each other’s types Library types provided by.NET Framework Class Library (FCL) Standardized Available in all languages All objects inherit from Object directly or indirectly

9 9 Datatype Value Types Enumeration Types Struct Types Standard/Simple Types Reference Types Pointer Types (discouraged even in C++) unmanaged code

10 10 CTS Simple Types Integral Types: byte8 bitsunsigned sbyte8 bitssigned char16 bitsunsigned unicode short16 bitssigned ushort16 bitsunsigned int32 bitssigned uint32 bitsunsigned long64 bitssigned ulong64 bitsunsigned Floating Point Type single 7 digitssigned double15-16 digitssigned Decimal Type Decimal28-29 significant digits signed Boolean Type bool8 bits(true or false)

11 11 CTS Reference Types Built-in object string (immutable) User-Defined classes Delegates

12 12 Visual Studio.NET 2003 Editor Powerful (and getting more powerful with 2005) Easy to use Syntax error detection Errors underlined in blue or red Hot keys for just about anything Customizable MSDN help built in (F1)

13 13 Default Shortcut Keys For a full list, search for “Shortcut” with the filter set to “Visual Studio Macros” Follow the link: “Default Settings Shortcut Keys”

14 14 Custom Shortcut Keys Go to Tools | Options | Environment | Keyboard Scroll through the actions listed, select the action you want Click in the “Press Shortcut Key(s)” box and press the keys you want to use It tells you, if that shortcut combination is being used and what it is being used by.

15 15 Collapsible Code regions use #region to start a region use #endregion to end a region use CTRL + M, CTRL + M to collapse the immediate region use CTRL + M, CTRL + L to toggle collapsing and expanding the entire file

16 16 XML Comments use “///” to add an XML Comment to your code XML Comments show up in the intellisense.

17 17 MSDN Documentation Search the index Use the filter Use the F1 key in your code Available online

18 18 Getting into the code using System; namespace HelloWorldProgram { class MyClass { static void Main() { Console.WriteLine(“Hello World”); } } }

19 19 C# Namespaces System System.Collections System.Data System.Diagnostics System.Globalization System.IO System.Net System.Reflection System.Resources System.Runtime System.Security System.Text System.Threading System.Timers System.Web System.Windows System.Windows.Forms System.Xml...and many more

20 20 Main( ) Main( ) must be static Main( ) can be public or private Doesn’t matter Only one Main( ) per class Can have multiple Main( )’s per program There is a command line switch to tell the compiler which Main() to use at startup

21 21 Main( ) Signatures Main() can have one of two different signatures Main( ) Main(string[] commandLineArguments) Main can have one of two different return types int or void static void Main(string[] args){ } static int Main(string[] args){ } static void Main(){ } static int Main(){ }

22 22 Anatomy of a Method Method ::= ([parameter list]) { } Parameter list ::= [ {, datatype identifier}] Example public void MyMethod(int myParam0, float myParam1) { //method body }

23 23 Simple Program using System; public class MainClass : object { [STAThread] static void Main() { Console.WriteLine(“Hello world.”); } (See Hello World Demo)

24 24 Compiling Command line: csc [filename] [options] VS: CTRL + SHIFT + B F5 (compiles and runs)

25 25 Preprocessor Search for “Preprocessor” with “Visual C#” filter


Download ppt "Overview CNS 3260 C#.NET Software Development. 2.NET Framework Began in 2000 Developed in three years (2000 to 2003) Operating System Hardware.NET Framework."

Similar presentations


Ads by Google