Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to C#

Introduction to C#

A basic introduction to the C# programming language, presented at a StudentGuru Patras event in November 2012

Konstantinos Goutsos

November 14, 2012
Tweet

More Decks by Konstantinos Goutsos

Other Decks in Programming

Transcript

  1.  Better approach to the real world  Modularity 

    Data Encapsulation  Code re-use  Pluggability and debugging Why use Object-Oriented Programming?
  2. automatic memory handling lots of libraries Why use Visual C#

    most code written for you desktop applications internet applications cross-platform object-oriented programming web+cloud services embedded systems
  3. Variables types & declaration • Supported types: integers, doubles, strings,

    dates and many more • Declaration: [type] name = [value]; • Example: string name="Konstantinos"; • Important: Assign with one = compare with two == • Don‘t forget to initialize your variables!
  4. • Declaration: [type][] name= {value, value, ….}; • For example:

    int[] numbers={0,1,2,3}; • Element reference: array[index]=5; • Memory is automatically allocated and cleaned Variables arrays
  5. • Same logic as in mathematics: = 22 + 3

    + 5 • Function declaration: [type] function_name ([type] arg1, [type] arg2,…) { statements; } Functions and methods the basics
  6. Control statements if clauses • if (condition) statement1; else statement2;

    • if (condition1) statement1; else if (condition2) statement2; else statement3; Example int age; boolean legalAge; if (age>=18) legalAge=true; else legalAge=false;
  7. switch (expression) { case 1: Console.WriteLine("Case 1"); break; case 2:

    Console.WriteLine("Case 2"); break; default: Console.WriteLine("Default case"); break; } Control statements switch statement
  8. for (int i = 1; i <= 5; i++) {

    Console.WriteLine(i); } int[] array={3,7,1,9}; foreach(int num in array){ Console.WriteLine(num); } Loop statements for and foreach
  9. • .NET Framework 4.5 support • Simpler asynchronous/threaded programming with

    the async and await keywords • Quicker debugging with Caller Information • Windows Store application support What’s new in Visual C# 2012
  10. • Support for Visual C#, Visual Basic, Visual F#, C,

    C++, ASP.NET, XNA • Complete development environment for major platforms including Windows desktop, Windows Store, Windows Phone, ΧΒox • Provides all the tools you might need to create pro-level applications Visual Studio
  11. • Download the at: msdn.upatras.gr • Login with your department

    credentials: eceXXXX or ceidXXXX Get Visual Studio 2012 for free
  12. • New look and feel including a dark theme (yay!)

    • Better faster IntelliSense • Support for .NET Framework 4.5 and Visual C# 2012 • Ability to develop for Windows Store and Windows Phone 8 • Blend for Visual Studio included Key new features
  13. • Microsoft Developer Network: msdn.microsoft.com • Visual C# in Visual

    Studio resources: http://bit.ly/OJFzDr • Active community at StackOverflow • StudentGuru: www.studentguru.gr • Contact us!! Visual C# Resources