Intro to C# and .NET
Jeff Klawiter
Senior Developer at
MCPD ASP.NET 2.0, MCTS: WinForms 2.0
http://www.jeffklawiter.com
http://nerdery.com/people/jk
C# History
ECMA 335
Need for a strong C based language for .NET
Borrows more syntax from Java and C than
C++
Static Typed
Current Version 3.0
.NET Overview
Standardized as ECMA 334
Managed memory
Common Type System
Languages may expose types differently
Common Language Runtime
Multiplelanguages can run together
Common Intermediate Language used as the
base language
Currently 20+ languages (including PHP)
.NET Platforms
Desktop SQL Server
Windows Forms Windows Services
WPF: Windows Console Applications
Presentation Foundation
Shell Scripting with
Mobile: Compact Powershell
Framework
Micro Framework
ASP.NET
Embedded development
Web Forms and MVC for sensors, embedded
Silverlight LCD touch screens, home
automation
XNA
2D and 3D video games COM objects
Surface Office Plugins
Specialized WPF with WCF
multi touch Multi Protocol Web
Services
HTTP, TCP, REST,
SOAP…
Variable Types
All types inherit from System.Object
Reference and Value Types
Reference Types represent a pointer to an object
in memory
Passed by reference
Fully mutable
Value Types represent primitive types
Passed by value
int, string, double
Inherits from System.ValueType
Data Types
byte decimal
sbyte IntPtr No built-in type.
short UIntPtr No built-in type.
int object
long string
ushort
uint
ulong
float
double
bool
char
Operators
Operator category Operators
Arithmetic + - * / %
Logical (boolean and bitwise) & | ^ ! ~ && || true false
String concatenation +
Increment, decrement ++ --
Shift << >>
Relational == != < > <= >=
Assignment = += -
= *= /= %= &= |= ^= <<= >>=
Member access .
Indexing []
Cast ()
Conditional ?:
Delegate concatenation and removal + -
Object creation new
Type information as is sizeof typeof
Advanced Features
Delegates
Referencable functions
Lambdas (x=>x.Name.StartsWith(“m”))
Anonymous Functions
inline delegates
Extension Methods
Add functions to class instance
Partial Classes
Split classes across multiple files
Partial Methods
Lightweight Events between partial class files.
Useful with tool generated code
LINQ: Language Integrated Query
var result = list.Where(x=>x.Name.StartsWith(“m”))
Demos
References
Visual C# 2008: The Language
Best C# book out there
Covers from novice to professional and beyond
Also covers visual studio
MonoDevelop
http://monodevelop.com/
Native C# development on Mac OS X and Linux
Visual C# Express 2008 (Free Visual Studio)
http://www.microsoft.com/Express/
0 comments
Post a comment