C# Tutorial - Ia802605.us.archive

1y ago
6 Views
2 Downloads
2.62 MB
216 Pages
Last View : 2m ago
Last Download : 3m ago
Upload by : Mollie Blount
Transcription

C# Tutorial

C# TUTORIALSimply Easy Learning by tutorialspoint.comtutorialspoint.comi

ABOUT THE TUTORIALC# TutorialC# is a simple, modern, general-purpose, object-oriented programming language developed by Microsoftwithin its .NET initiative led by Anders Hejlsberg.This tutorial will teach you basic C# programming and will also take you through various advanced conceptsrelated to C# programming language.AudienceThis tutorial has been prepared for the beginners to help them understand basic C# programming. Aftercompleting this tutorial, you will find yourself at a moderate level of expertise in C# programming fromwhere you can take yourself to next levels.PrerequisitesC# programming is very much based on C and C programming languages, so if you have basicunderstanding on C or C programming, then it will be a fun to learn C# programming language.Copyright & Disclaimer Notice Allthe content and graphics on this tutorial are the property of tutorialspoint.com. Any content fromtutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or form withoutthe written permission of tutorialspoint.com. Failure to do so is a violation of copyright laws.This tutorial may contain inaccuracies or errors and tutorialspoint provides no guarantee regarding theaccuracy of the site or its contents including this tutorial. If you discover that the tutorialspoint.com site orthis tutorial content contains some errors, please contact us at webmaster@tutorialspoint.comTUTORIALS POINTSimply Easy Learning

Table of ContentC# Tutorial . 2Audience . 2Prerequisites . 2Copyright & Disclaimer Notice . 2C# Overview . 11Strong Programming Features of C# . 11C# Environment . 13The .Net Framework . 13Integrated Development Environment (IDE) For C# . 14Writing C# Programs on Linux or Mac OS . 14C# Program Structure . 15C# Hello World Example . 15Compile & Execute a C# Program: . 16C# Basic Syntax . 18The using Keyword . 19The class Keyword . 19Comments in C# . 19Member Variables . 19Member Functions . 19Instantiating a Class . 19Identifiers . 20C# Keywords . 20C# Data Types . 22Value Types. 22Reference Types . 23OBJECT TYPE . 23DYNAMIC TYPE. 23STRING TYPE. 24Pointer Types . 24C# Type Conversion . 25C# Type Conversion Methods . 25C# Variables . 28Variable Declaration in C# . 28Variable Initialization in C# . 29Accepting Values from User . 29Lvalues and Rvalues in C#: . 30C# Constants and Literals . 31TUTORIALS POINTSimply Easy Learning

Integer Literals . 31Floating-point Literals . 31Character Constants. 32String Literals. 33Defining Constants . 33C# Operators . 34Arithmetic Operators. 34Example . 35Relational Operators. 35Example . 36Logical Operators . 37Example . 37Bitwise Operators . 38Example . 39Assignment Operators . 40Example . 40Misc Operators . 42Example . 42Operators Precedence in C# . 43Example . 43C# Decision Making . 45If statement . 46Syntax: . 46Flow Diagram: . 46Example: . 46If else statement. 47Syntax: . 47Example: . 48The if.else if.else Statement . 49Syntax: . 49Example: . 49nested if statements . 50Syntax: . 50Example: . 50switch statement . 51Syntax: . 51Flow Diagram: . 52Example: . 52nested switch statement . 53TUTORIALS POINTSimply Easy Learning

Syntax: . 53Example: . 53The ? : Operator: . 54C# Loops. 55while loop . 56Syntax: . 56Flow Diagram: . 56Example: . 57for loop . 57Syntax: . 57Flow Diagram: . 58Example: . 58do while loop . 59Syntax: . 59Flow Diagram: . 60Example: . 60nested loops . 61Syntax: . 61Example: . 61Loop Control Statements: . 62break statement . 63Syntax: . 63Flow Diagram: . 63Example: . 63continue statement . 64Syntax: . 64Flow Diagram: . 65Example: . 65The Infinite Loop: . 66C# Encapsulation . 67Public Access Specifier . 67Private Access Specifier . 68Protected Access Specifier . 69Internal Access Specifier . 69Protected Internal Access Specifier . 70C# Methods. 71Defining Methods in C# . 71Example: . 71Calling Methods in C# . 72TUTORIALS POINTSimply Easy Learning

Recursive Method Call . 73Passing Parameters to a Method . 74Value parameters . 74Reference parameters . 75Output parameters. 77C# Nullables. 79The Null Coalescing Operator (?) . 80C# Arrays . 81Declaring Arrays . 81Initializing an Array . 81Assigning Values to an Array. 82Accessing Array Elements . 82Using the foreach Loop . 83C# Arrays in Detail. 84Initializing Two-Dimensional Arrays . 85Accessing Two-Dimensional Array Elements . 85Methods of the Array Class . 89Example . 90C# Strings . 92Creating a String Object . 92Properties of the String Class . 93Methods of the String Class. 93Examples: . 95Comparing Strings: . 95C# Structures . 98Defining a Structure . 98Features of C# Structures . 99Class vs Structure . 100C# Enums . 102Declaring enum Variable . 102Example: . 102C# Classes. 104Class Definition. 104Member Functions and Encapsulation . 105Constructors in C# . 107Destructors in C# . 108Static Members of a C# Class . 109C# Inheritance. 111Base and Derived Classes . 111TUTORIALS POINTSimply Easy Learning

Base Class Initialization . 112Multiple Inheritance in C# . 113C# Polymorphism . 115Static Polymorphism . 115Function Overloading . 115Dynamic Polymorphism . 116C# Operator Overloading . 119Implementation of Operator Overloading . 119Overloadable and Non-Overloadable Operators . 121Example: . 121C# Interfaces. 125Declaring Interfaces. 125Example . 125C# Namespaces. 127Defining a Namespace . 127The using Keyword . 128Nested Namespaces . 129C# Preprocessor Directives . 131List of Preprocessor Directives in C# . 131The #define Preprocessor . 132Conditional Directives . 132C# Regular Expressions. 134Constructs for Defining Regular Expressions . 134Character escapes . 134Character classes . 135Anchors . 136Grouping constructs . 136Quantifiers . 137Backreference constructs . 138Alternation constructs . 138Substitution . 138Miscellaneous constructs . 139The Regex Class . 139Example 1. 140Example 2. 140Example 3. 141C# Exception Handling . 142Syntax . 142Exception Classes in C# . 143TUTORIALS POINTSimply Easy Learning

Handling Exceptions . 143Creating User-Defined Exceptions . 144Throwing Objects . 145C# File I/O . 146C# I/O Classes . 146The FileStream Class . 147Example: . 147Advanced File Operations in C# . 148The StreamReader Class . 148Example: . 149The StreamWriter Class . 150Example: . 150The BinaryReader Class . 151The BinaryWriter Class . 152Example . 152The DirectoryInfo Class . 154The FileInfo Class. 155Example . 156C# Attributes . 157Specifying an Attribute . 157Predefined Attributes . 157AttributeUsage: . 157Conditional. 158Obsolete . 159Creating Custom Attributes . 160Declaring a Custom Attribute . 160Constructing the Custom Attribute . 160Applying the Custom Attribute . 162C# Reflection . 163Uses of Reflection . 163Viewing Metadata . 163Example . 164C# Properties . 168Accessors . 168Example: . 169Abstract Properties . 170C# Indexers. 173Syntax . 173Use of Indexers . 173TUTORIALS POINTSimply Easy Learning

Overloaded Indexers . 175C# Delegates . 177Declaring Delegates . 177Instantiating Delegates . 177Multicasting of a Delegate . 178Use of Delegate . 179C# Events . 181Using Delegates with Events . 181Declaring Events . 181Example 1:. 181Example 2:. 182C# Collections . 185Various Collection Classes and Their Usage . 185Methods and Properties of the ArrayList Class. 186Example: . 187Example: . 188Methods and Properties of the SortedList Class. 190Example: . 191Methods and Properties of the Stack Class . 192Example: . 192Methods and Properties of the Queue Class . 193Example: . 194Example: . 195C# Generics . 198Features of Generics . 199Generic Methods . 199Generic Delegates . 200C# Anonymous Methods . 202Syntax for Writing an Anonymous Method . 202Example: . 202C# Unsafe Codes . 204Pointer Variables . 204Retrieving the Data Value Using a Pointer . 205Passing Pointers as Parameters to Methods . 206Accessing Array Elements Using a Pointer . 207Compiling Unsafe Code . 208C# Multithreading . 209Thread Life Cycle . 209The Main Thread . 209TUTORIALS POINTSimply Easy Learning

Commonly Used Properties and Methods of the Thread Class . 210Creating Threads . 212Managing Threads. 213Destroying Threads . 214TUTORIALS POINTSimply Easy Learning

1CHAPTERC# OverviewC# is a modern, general-purpose, object-oriented programming language developed by Microsoft andapproved by Ecma and ISO.C# was developed by Anders Hejlsberg and his team during the development of .Net Framework.C# is designed for Common Language Infrastructure (CLI), which consists of the executable code and runtimeenvironment that allows use of various high-level languages to be used on different computer platforms andarchitectures.The follow

All the content and graphics on this tutorial are the property of tutorialspoint.com. Any content from tutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or form without . Windows, Solaris and UNIX. TUTORIALS POINT Simply Easy Learning

Related Documents:

Archiving & retrieval processes Archiving is driven by archive management - Select data to be archived from archive source - Transfer data into archive management system - Extract metadata and store this as index - Store data in archive storage Retrieve is drive through archive management - Provide search & discovery function to find data

Dawah for Jews 11 After the Christians decided to incorporate the Old Testament into their Bible, they began to study these books in great detail. Preservation of Quran Quran was written during Prophet Muhammad (PBUH)’s life time by his noble

Tutorial Process The AVID tutorial process has been divided into three partsÑ before the tutorial, during the tutorial and after the tutorial. These three parts provide a framework for the 10 steps that need to take place to create effective, rigorous and collaborative tutorials. Read and note the key components of each step of the tutorial .

Tutorial Process The AVID tutorial process has been divided into three partsÑ before the tutorial, during the tutorial and after the tutorial. These three parts provide a framework for the 10 steps that need to take place to create effective, rigorous and collaborative tutorials. Read and note the key components of each step of the tutorial .

Tutorial 1: Basic Concepts 10 Tutorial 1: Basic Concepts The goal of this tutorial is to provide you with a quick but successful experience creating and streaming a presentation using Wirecast. This tutorial requires that you open the tutorial document in Wirecast. To do this, select Create Document for Tutorial from the Help menu in Wirecast.

Tutorial 16: Urban Planning In this tutorial Introduction Urban Planning tools Zoning Masterplanning Download items Tutorial data Tutorial pdf This tutorial describes how CityEngine can be used for typical urban planning tasks. Introduction This tutorial describes how CityEngine can be used to work for typical urban .

Tutorial 1: Basic Concepts 10 Tutorial 1: Basic Concepts The goal of this tutorial is to provide you with a quick but successful experience creating and streaming a presentation using Wirecast. This tutorial requires that you open the tutorial document in Wirecast. To do this, select Create Document for Tutorial from the Help menu in Wirecast.

Implication zootechnique du menthol cristallisé comme additif. alimentaire chez le poulet de chair. E. AZEROUAL. 1, M. OUKESSOU. 2, K. BOUZOUBAA. 2, A. MESFIOUI. 1, B. BENAZZOUZ & A. OUICHOU (Reçu le 15/04/2012; Accepté le 18/06/2012) Résumé. Le menthol est utilisé pour ses vertus aromatiques, culinaires, cosmétiques et médicinales. Chez l’homme, il est employé contre les . troubles .