Your SlideShare is downloading. ×
0
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
TechTalk - Dotnet
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

TechTalk - Dotnet

1,379

Published on

Published in: Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,379
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Coding Guidelines Sprache
  • Transcript

    • 1. Tech Talk – C# und das Microsoft .NET Framework Heinrich Wendel, DLR Simulations- und Softwaretechnik 30. Juli 2008
    • 2. Entstehungsgeschichte
      • Microsofts Dominanz der PC-Kerntechnologien in Gefahr
      • Wunsch nach konkurrenzfähiger Technik „gegen Java“
      • Alte, nicht zueinander kompatible Windows Technologien ersetzen
    • 3. History
      • 2000: Bill Gates stellt die .NET- „Vision“ vor
      • 2002: .NET (V1.0) mit SDK wird vorgestellt
      • 2003: .NET 1.1 und Visual Studio 2003
      • 2005: Release des .NET Framework 2.0 und Visual Studio 2005
      • 2006: .Net Framework 3.0 verfügbar
      • 2007: .NET 3.5 und Visual Studio 2008
    • 4. Architektur
    • 5. Common Language Infrastructure
      • Common Language Specification
        • Minimales Set an Features zur Kompatibilität zwischen Sprachen
        • [ClsCompliant(true)]
      • Beispiel
        • Pointer
        • unsigned Typen
        • Groß/Kleinschreibung
      • Common Type System
    • 6. Interoperabilität
    • 7. Assemblies
      • Bibliothek enthält CIL Code, Dateitype .dll / .exe
        • Name
        • Version
        • Kultur (Satellite assemblies)
        • Public Key (Strong name)
      • Global Assembly Cache
      • Eingebettete Resourcen
      • Manifest
    • 8. Dynamic Assembly loading
      • Assemblies können dynamisch zur Laufzeit geladen aber nicht entladen werden
      • Application Domains (vgl. OSGi)
        • Abgetrennte Bereiche
        • Sicherheit
        • Konfiguration
        • ExceptionHandling
        • Können gestartet und gestoppt werden
        • Kommunikation über .NET Remoting
    • 9. C# - Namespaces // Defining namespaces namespace Dlr.Sistec { class Test { … } } // Nested namespaces namespace Dlr { namespace Sistec { class Test {…} } } // Using namespaces Dlr.Sistec.Test = new Dlr.Sistec.Test(); // Short form Using Dlr.Sistec; Test = new Test(); // Aliases Using ns = Dlr.Sistec; ns.Test = new ns.Test();
    • 10. C# - Control Flow
      • Iteration
        • For
        • Foreach
        • While
        • Do…While
      • Kontrollstrukturen
        • If/else if/else
        • Kurzfassung: Bedingung ? Anweisung1 : Anweisung2
        • Switch
    • 11. C# - Iterators Months months = new Months(); foreach (string temp in months) Console.WriteLine(temp); public class Months : IEnumerable {   string[] month = { &quot;Januar&quot;, &quot;Februar&quot;, &quot;März&quot;, &quot;April&quot;, &quot;Mai&quot;, &quot;Juni&quot;, &quot;Juli&quot;, &quot;August&quot;, &quot;September&quot;, &quot;Oktober&quot;, &quot;November&quot;, &quot;Dezember&quot;};   public IEnumerator GetEnumerator() {     for (int i = 0; i < month.Length; i++)       yield return month[i];   } }
    • 12. C# - Switch / Enums string s = Console.ReadLine();; switch(s) { case „ January “: … break; case „ Februar “: … break; case „ March “: … break; … }
    • 13. C# - Switch / Enums
      • public Enum Month {
        • January = 1,
        • Februar = 2,
        • March = 3
      • }
      Month m = …; switch (m) { case Month.January : break; case Month.February : break; case 3 : break; … }
    • 14. C# - Switch / Enums [Flags] public enum Keys { Shift = 1, Ctrl = 2, Alt = 4 } Keys k = Keys.Shift | Keys.Ctrl if ((k & Keys.Shift) == Keys.Shift) {…}
    • 15. C# - Indexer String[] People = { „Schreiber, „Legenhausen“, „Wendel“}; Console.Write( People[0] ) People[1] = Console.ReadLine()
      • public dataType this[int index]
      • {
      • get
      • {
        • /// …
      • }
      • set
      • {
        • /// …
      • }
      • }
    • 16. C# - Properties public class Person { private string firstName ; private string lastName ; public void setFirstName (string name) this.firstName = name; } public string getLastName () return this.lastName; } public void setLastName (string name) this.lastName = name } public string getFirstName () return this.firstName; } } public class Person { public string FirstName { get { return firstName; } set { firstName = value ; } } private string firstName ; public string LastName { get { return lastName; } set { lastName = value ; } } private string lastName ; } Public class Person { public string FirstName { get; set ; } public string LastName { get; set ; } }
    • 17. C# - Attributes
      • Annotations in Java / Decorators in Python
      • Anwendbar auf Assemblies, Klassen, Methoden, Felder …
      • Vordefinierte Attribute
        • [Serializable]
        • [ClsCompliant(true)]
        • [Obsolete]
      • Eigene Attribute
    • 18. C# - Attributes [AttributeUsage(AttributeTargets.All)] public class DeveloperAttribute : Attribute { public string Zuname; public int PersID; public DeveloperAttribute(string name) { Zuname = name; } } [DeveloperAttribute(&quot;Meier&quot;, PersID = 8815)] class Program { static void Main(string[] args) { DeveloperAttribute attr = (DeveloperAttribute)Attribute. GetCustomAttribute(typeof(Program), typeof(DeveloperAttribute)); Console.WriteLine(&quot;Name: {0}&quot;, attr.Zuname ); Console.WriteLine(&quot;PersID: {0}&quot;, attr.PersID ); }
    • 19. C# - Delegates / Events public class Logger { public delegate void Log(string message); private static Log log ger ; public static void Main(string[] args) { log ger = new Log(PrintToConsole); log ger.Invoke (&quot;message&quot;); } public static void PrintToConsole(string message) { Console.WriteLine(message); } } public class Logger { public delegate void Log(string message); private static Log logList; public static void Main(string[] args) { logList += new Log(PrintToConsole); logList += new Log(PrintTo File ); logList (&quot;message&quot;); } public static void PrintToConsole (string message) { … } public static void PrintTo File (string message) { … } } public class Logger { public delegate void Log(string message); public static event Log logList ; public static void Main(string[] args) { logList += PrintToConsole; logList += PrintTo File ; logList (&quot;message&quot;); } public static void PrintToConsole (string message) { … } public static void PrintTo File (string message) { … } }
    • 20. C# - Lambda Funktionen public class Logger { public delegate void Log(string message); private static Log logList; public static void Main(string[] args) { logList = delegate(string message) { Console.WriteLine(message); }; logList(&quot;message&quot;); } } public class Logger { public delegate void Log(string message); private static Log logList; public static void Main(string[] args) { logList = message => { Console.WriteLine(message); }; logList(&quot;message&quot;); } } List <int> evenNumbers = list.FindAll( i => (i%2) == 0 );
    • 21.
      • Queries auf IEnumerable<T>, Relationale Datenbanken, XML Dateien
      • from, in, where, select, join, on, equals, into, orderby, ascending, descending, group, by
      C# - LINQ int[] numbers = { 10, 20, 30, 40, 1, 2, 3, 8 }; var subset = from i in numbers where i < 10 select i ; foreach (int i in subset) Console.WriteLine(i);
    • 22. C# - Structs
      • Fast alle Features einer Klasse
      • Keine Vererbung
      • Value Types statt Reference Types
      public struct Point { int x {get; set} int y {get; set} public Point(int x, int y) { … } public int getDistance(int x, int y) { … } public static Point operator +(Point p) {…} }
    • 23. C# - Constructors public class Point { public Point(int x, int y) { X = x; Y = y; } public Point() { } public int X { get; set; } public int Y { get; set; } } Point p = new Point(1, 2) Point p = new Point() P.X = 1; p.Y = 2; Point p = new Point { X = 1, Y = 2 }
    • 24. C# - Constructors public class Point { public int X { get; set; } public int Y { get; set; } } public class Rectangle { public Point topLeft { get; set; } public Point bottomRight { get; set; } } Rectangle r = new Rectangle { topLeft = new Point{ X = 0, Y = 0 }, bottomRight = new Point { X = 2, Y = 2 } } Rectangle r = new Rectangle(); Point p1 = new Point(); p1.X = 0; p1.Y = 0; Point p2 = new Point(); p2.X = 2; p2.Y = 2; r.topLeft = p1; r.bottomRight = p2;
    • 25. C# - Unsafe Code
      • Erlaubt Pointer-Operationen
      • unsafe keyword
      • Höhere Performance
      • Fixed keyword
      int var1 = 5; unsafe { int * ptr1, ptr2; ptr1 = & var1; ptr2 = ptr1; *ptr2 = 20; } Console.WriteLine(var1);
    • 26. C# - Preprocessor
      • #define / #undef
      • #if / #else / #elif / #endif
      • #region / #endregion
    • 27. C# - Exception Handling
      • try / catch / finally
      • Python like statt Java like
        • Exceptions müssen nicht gefangen und deklariert werden!
        • Nicht mehrere in einem catch-Block behandelbar
      • Exception Klasse
        • TargetSite
        • StackTrace
        • HelpLink
        • Data
      • Eigene Exceptions sollen von ApplicationException ableiten
        • SystemException
          • IndexOutOfRangeException
          • NullReferenceException
    • 28. C# - Method Calls void FunctionA( ref int Val) { int x= Val; Val = x* 4; } int a= 5; FunctionA( ref a); Console.WriteLine(a); bool GetNodeValue( out int Val) { Val = 1; return true; } int Val; GetNodeValue(Val); Console.WriteLine(a); void Func(params int[] array) { Console.WriteLine(array.Length); } Func(1); Func(7,9); Func(new int[] {3,8,10});
    • 29. C# - Extension Methods public static class ExtensionClass { public static int MultiplyByTwo( this int number) { return number * 2; } } public class Class1 { public static void Main(string[] args) { int number = 2; Console.WriteLine( number.MultiplyByTwo() ); } }
    • 30. C# - Casting object [] myObjects = new object[1] myObjects[0] = new MyClass1(); string s; // Exception s = (string) myObjects[0] public static explicit operator String(MyClass1) { return “SomeString”; } If (myObjects[0] is string) { s = (string) myObjects[1] } s = myObjects[0] as string
    • 31. C# - Keywordmania
      • sealed
      • internal / protected internal
      • const
      • readonly
      • this / base
      • nullable (?)
      • partial
      • (un)checked
      • abstract / virtual / override / new
    • 32. C# - Was sonst noch geht …
      • Generics
      • Operatoren überladen
        • Strings können mit == übeprüft werden
      • Auto(un)boxing
      • Eigene Listen (System.Collecions / System.Collections.Generic)
      • Sortierung (IComparable / ICompare)
      • String formatierung (String.Format)
    • 33. Library
      • Isolated Storage
      • ADO.NET
      • Windows Communication Foundation
      • Windows Workflow Foundation
      • Windows Forms
      • Windows Presentation Foundation
    • 34. Parallel Programming
      • Builtin Mechanisms:
        • Locks
        • Monitors
        • synchronisation keyword
        • Threads
      • ParallelFX
        • Parallel.For
      • LINQ per default parallelisiert
    • 35. Entwicklungsumgebungen
      • Microsoft Visual Studio
        • Express
        • Standard
        • Professional
        • Team System (Architecture-, Database-, Development-, Test- Edition)
      • (http://msdn.microsoft.com/de-de/vs2008/cc149003.aspx)
      • SharpDevelop
      • MonoDevelop
    • 36. Tools
      • Nunit
      • Ndoc
      • FxCop
      • Lutz Roeder's Reflector
      • NAnt
    • 37. Lizenzen
      • CLI und C#: ECMA Standard
        • VM (CIL)
        • C# Compiler
        • Neue Sprachen
      • Klassenbibliotheken und andere Teile: shared source
        • WindowsForms
        • ADO.NET
        • ASP.NET
    • 38. Alternative .NET Implementierungen
      • Mono
      • DotGNU
      • CrossNet (Assemblies to Unmanaged C++)
      • .NET for Symbian
      • Shared Source Common Language Infrastructure (MS)
    • 39. IKVM.NET
      • Java für .NET
      • Java Virtual Machine
      • .NET implementation der Java Klassenbibliothek
      • Tools um Java und .NET Programme zu verbinden
      • Java Bytecode in einer JVM auf der CLR laufen lassen
      • Java in CLI compilieren
      • Noch kein AWT/Swing
    • 40. IronPython
      • Implementiernug von Python für .NET
      • Keine C-Extensions (e.g. NumPy)
        • Ironclad
      • Dynamic Language Runtime
        • Dynamic Type System
        • JScript
        • VBx
      • Integration in Silverlight Applikationen
    • 41.  

    ×