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


  1. Konstantinos Goutsos Undergraduate student – ECE Department StudentGuru Patras Member

  2. Object-Oriented Programming

  3. objects properties Object-Oriented Programming methods classes inheritance interfaces the basics

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

    Data Encapsulation  Code re-use  Pluggability and debugging Why use Object-Oriented Programming?
  5. color manufacture date Car speed brake() changeGear() accelerate() our sample

    class gear
  6. Car class implementation in C#

  7. Visual C# 2012

  8. 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
  9. 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!
  10. • 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
  11. • Same logic as in mathematics: = 22 + 3

    + 5 • Function declaration: [type] function_name ([type] arg1, [type] arg2,…) { statements; } Functions and methods the basics
  12. 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;
  13. 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
  14. 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
  15. while (condition) { Console.WriteLine("StudentGuru rocks!!"); } int i=2012; do{ Console.WriteLine(i);

    } while (condition) Loop statements while and do
  16. • .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
  17. Visual Studio 2012

  18. • 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
  19. • Download the at: • Login with your department

    credentials: eceXXXX or ceidXXXX Get Visual Studio 2012 for free
  20. • 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
  21. Web Browser Demo

  22. • Microsoft Developer Network: • Visual C# in Visual

    Studio resources: • Active community at StackOverflow • StudentGuru: • Contact us!! Visual C# Resources