Programming in C#. I. Introduction C# (or C-Sharp) is a programming language. C# is used to write software that runs on the.NET Framework. Although C#

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

Introduction to .NET Framework
Tahir Nawaz Introduction to.NET Framework. .NET – What Is It? Software platform Language neutral In other words:.NET is not a language (Runtime and a.
The Web Warrior Guide to Web Design Technologies
Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
 C++ programming facilitates a disciplined approach to program design. ◦ If you learn the correct way, you will be spared a lot of work and frustration.
Chapter 1: Introduction
Introduction to the C# Programming Language for the VB Programmer.
C# Programming: From Problem Analysis to Program Design1 2 Your First C# Program C# Programming: From Problem Analysis to Program Design 2 nd Edition.
Introduction to Computing and Programming
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
Copyright 2013 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
1 Building Java Programs Chapter 1: Introduction to Java Programming These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may.
An Introduction to C# and the .NET Framework
Rajeswari Indupuri Introduction to.NET Framework.
Microsoft Visual Basic 2012 CHAPTER ONE Introduction to Visual Basic 2012 Programming.
Microsoft Visual Basic 2005 CHAPTER 1 Introduction to Visual Basic 2005 Programming.
Creating and Running Your First C# Program Telerik Software Academy Telerik School Academy.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
Introducing Java.
A First Program Using C#
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
High thoughts must have high language. Aristophanes
Module 1: Introduction to C# Module 2: Variables and Data Types
 2002 Prentice Hall. All rights reserved. 1 Introduction to Visual Basic.NET,.NET Framework and Visual Studio.NET Outline 1.7Introduction to Visual Basic.NET.
Introduction to .NET Framework
Lecture Set 1 Part B: Understanding Visual Studio and.NET – Structure and Terminology 1/16/ :04 PM.
Understanding Code Compilation and Deployment Lesson 4.
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
Compiling and Executing Code in.Net Microsoft Intermediate Language and Common Language Runtime.
C# B 1 CSC 298 Writing a C# application. C# B 2 A first C# application // Display Hello, world on the screen public class HelloWorld { public static void.
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
Computing with C# and the.NET Framework Chapter 1 An Introduction to Computing with C# ©2003, 2011 Art Gittleman.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
1 Introduction to C# Programming Console applications No visual components Only text output Two types MS-DOS prompt - Used in Windows 95/98/ME Command.
Week 1: THE C# LANGUAGE Chapter 1: Variables and Expressions ➤ Included in Visual Studio.NET ➤ What the.NET Framework is and what it contains ➤ How.NET.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
 JAVA Compilation and Interpretation  JAVA Platform Independence  Building First JAVA Program  Escapes Sequences  Display text with printf  Data.
Introduction to .NET Framework
Week 1 Algorithmization and Programming Languages.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
1 Introduction to C# Programming Console applications No visual components Only text output Two types MS-DOS prompt - Used in Windows 95/98/ME Command.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Getting Started with.NET Getting Started with.NET/Lesson 1/Slide 1 of 31 Objectives In this lesson, you will learn to: *Identify the components of the.NET.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 – Introduction to C# Programming Outline 3.1 Introduction 3.2 Simple Program: Printing a Line.
INTRODUCTION CHAPTER #1 Visual Basic.NET. VB.Net General features It is an object oriented language  In the past VB had objects but focus was not placed.
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Lecture Set 1 Part B: Understanding Visual Studio and.NET – Structure and Terminology 1/16/ :04 PM.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
Microsoft Visual Basic 2015 CHAPTER ONE Introduction to Visual Basic 2015 Programming.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
Introduction to Visual Basic. NET,. NET Framework and Visual Studio
Introduction to .NET Framework
CSC201: Computer Programming
Introduction to Visual Basic 2008 Programming
Chapter 2, Part I Introduction to C Programming
CSE 190D, Winter 2013 Building Java Programs Chapter 1
C# and the .NET Framework
Introduction to .NET Framework Ch2 – Deitel’s Book
Advanced Programming Lecture 02: Introduction to C# Apps
Chapter 3 – Introduction to C# Programming
Computer Programming-1 CSC 111
IS 135 Business Programming
Presentation transcript:

Programming in C#

I. Introduction C# (or C-Sharp) is a programming language. C# is used to write software that runs on the.NET Framework. Although C# is not the only language that you can use to target the.NET Framework, C# is one of the most popular because of its simplified C-based syntax.

I. Introduction In brief, C# (unlike C++, PERL, COBOL, Pascal, etc.) is a language that targets one and only one platform. This platform is the.NET Framework. However, the.NET Framework itself is a computing platform that is designed to be hosted by any operating system.

I. Introduction So you can see that although C# is designed to target only the Framework, the Framework itself is flexible enough to run your C# programs on many types of systems.

C# Language Features Arrays Constructors and Destructors Indexers Main Properties Passing Parameters

Introducing the Building Blocks of the.NET Platform (the CLR, CTS, and CLS) Central.Net Framework is its runtime execution environment, known as Common Language Runtime. Code running under the control of CLR is often termed as Manage Code. Before it executed in CLR,any source code that you develop in C# needs to be compiled.

Compilation occurs in two steps in.Net Compilation of source code to intermediate Language. Compilation of IL to platform–specific code By the CLR

Common Language Runtime (CLR) Central part of framework Executes programs Compilation process Two compilations take place Programs compiled to Microsoft Intermediate Language (MSIL) Defines instructions for CLR MSIL code translated into machine code Platform-specific machine language

Common Language Runtime (CLR) Why two compilations? Platform independence.NET Framework can be installed on different platforms Execute.NET programs without any modifications to code.NET compliant program translated into platform independent MSIL Language independence MSIL form of.NET programs not tied to particular language Programs may consist of several. MSIL translated into platform-specific code Other advantages of CLR Execution-management features Manages memory, security and other features Relieves programmer of many responsibilities More concentration on program logic

Common Type System Another building block of the.NET platform is the Common Type System, or CTS. The CTS defines a set of rules that language compilers must follow to define,reference, use and store reference and value types. Therefore, by following the CTS, objects written in different languages can interact with each other.

Common Language system The CLS is the minimum specification of requirements that a language must support.This means that if you restrict your public methods to CLS,all Languages supporting.Net can use your classes.

Visual Studio 2005 Integrated Development Environment.NET initiative Independence from specific language or platform Applications developed in any.NET-compatible language Visual Basic.NET, Visual C++.NET, C# and more

.NET and C#.NET platform Web-based applications can be distributed to variety of devices and desktops C# Developed specifically for.NET Enable programmers to migrate from C/C++ and Java easily Event-driven, fully OO, visual programming language Has IDE Process of rapidly creating an application using an IDE is called Rapid Application Development (RAD)

XML Documentation Comments (C# Programming Guide) In Visual C# you can create documentation for your code by including XML tags in special comment fields in the source code directly before the code block they refer to. For example: /// /// This class performs an important function. /// public class MyClass{}

Constants Constants are immutable(not change) values which are known at compile time and do not change for the life of the program. Constants are declared with the const modifier.const Constants must be initialized as they are declared. For example: class Calendar1 { public const int months = 12; }

Escape Sequences Escape sequences are typically used to specify actions such as carriage returns and tab movements on terminals and printers. They are also used to provide literal representations of nonprinting characters and characters that usually have special meanings, such as the double quotation mark ("). The following table lists the escape sequences and what they represent.

Escape Sequences Character Meaning in Life \' Inserts a single quote into a string literal. \" Inserts a double quote into a string literal. \\ Inserts a backslash into a string literal. This can be quite helpful when defining file paths. \a Triggers a system alert (beep). For console applications, this can be an audio clue to the user. \n Inserts a new line (on Win32 platforms). \r Inserts a carriage return. \t Inserts a horizontal tab into the string literal.

C# String Literal Literals are how you hard-code strings into C# programs. As another example, assume you wish to create a string literal that contains quotation marks, another that defines a directory path, and a final string literal that inserts three blank lines after printing the character data. To do so without compiler errors, you would need to make use of the \", \\, and \n escape characters:

example Console.WriteLine("Everyone loves \"Hello World\"");

Keywords Keywords are predefined reserved identifiers that have special meanings to the compiler.

Keywords

Methods Building blocks of C# programs Every program is a class! The Main method Each console or windows application must have exactly one

Getting input Data types built into C# (string, int, double, char, long …15 types) Console.ReadLine( ) Used to get a value from the user input

// 2 // A first console program in C#. 3 4 using System; 5 6 class Welcome1 7 { 8 static void Main( string[] args ) 9 { 10 Console.WriteLine( "Welcome to C# Programming!" ); 11 } 12 }

// 2 // Printing a line with multiple statements. 3 4 using System; 5 6 class Welcome2 7 { 8 static void Main( string[] args ) 9 { 10 Console.Write( "Welcome to " ); 11 Console.WriteLine( "C# Programming!" ); 12 } 13 }

Simple Program: Output

1 // 2 // Printing multiple lines in a dialog Box. 3 4 using System; 5 using System.Windows.Forms; 6 7 class Welcome4 8 { 9 Static void Main( string[] args ) 10 { 11 MessageBox.Show( “ Welcome\nto\nC#\nprogramming!" ); 12 } 13 } The System.Windows.Forms namespace allows the programmer to use the MessageBox class. This will display the contents in a message box as opposed to in the console window.