C# is an object-oriented programming language developed by Microsoft for the .NET Framework. It incorporates features from Java but is used to develop both executable applications and reusable component libraries. The document provides an overview of C# programming concepts like classes, methods, inheritance and discusses features like boxing, properties and constructors.
Java vs. C#
The document compares Java and C# programming languages. It discusses some key differences:
1. Syntax differences such as main method signatures, print statements, and array declarations are slightly different between the two languages.
2. Some concepts are modified in C# from Java, such as polymorphism requiring the virtual keyword, operator overloading restrictions, and switch statements allowing string cases.
3. C# introduces new concepts not in Java like enumerations, foreach loops, properties to encapsulate fields, pointers in unsafe contexts, and passing arguments by reference.
The document provides information about C and C Sharp programming languages. It discusses the history, features, data types, loops, conditional statements, functions, arrays, pointers, object-oriented concepts like inheritance, encapsulation, polymorphism in both the languages. It also highlights some advantages of C Sharp over C like automatic memory management, no need of header files etc.
This document compares features between Java and C# programming languages. It outlines that C# supports features like events, delegates, properties, operator overloading, and pointers that are absent in Java. Meanwhile, Java supports features like checked exceptions and strictfp keyword that are not present in C#. There are also some philosophical differences between the two languages, such as how methods are handled and whether exceptions are checked. Overall, the document provides a detailed overview of similarities and differences between the Java and C# programming languages.
C is a general-purpose high level language that was originally developed by Dennis Ritchie for the Unix operating system. It was first implemented on the Digital Equipment Corporation PDP-11 computer in 1972.
The document provides an overview of C++ vs C# by Shubhra Chauhan. It discusses the key object-oriented programming concepts like classes, objects, inheritance, polymorphism, and how they are implemented in C++ and C#. It includes code examples to demonstrate class usage and inheritance in both languages. The document also compares some similarities and differences between C++ and C# like support for pointers, preprocessors, structures, and goto statements.
C++ and C# are compared, with key differences noted such as C++ compiling to machine code while C# compiles to CLR. An algorithm to calculate rectangle area is presented, with programs in C++ and C# provided as examples. The conclusion states that C# is better than C++ in performance, usability and durability due to features like automatic memory management that C# has which C++ lacks.
This document provides an overview and structure of a course on advanced C language for engineering. It discusses topics that will be covered including the FILE methodology, literate programming with cweb tools, classes for embedded systems, and using C with Lex and YACC for linguistic support. The document outlines the overall structure of the course and provides examples to introduce fundamental C concepts like variables, data types, loops, conditional statements, and functions.
Complete C++ programming Language CourseVivek chan
This document provides an overview of topics covered in a C++ programming course, including:
- Introduction to C++ language fundamentals like data types, variables, operators, control structures, functions, and classes
- Memory concepts, arithmetic, decision making, and algorithms
- Structured and object-oriented programming principles
- The basics of the C++ environment like compilers, linkers, and input/output streams
- Common library functions and concepts like headers, prototypes, and enumerations
The document serves as an introductory reference for anyone learning C++ or wanting to understand the basic building blocks of the language.
Java vs. C#
The document compares Java and C# programming languages. It discusses some key differences:
1. Syntax differences such as main method signatures, print statements, and array declarations are slightly different between the two languages.
2. Some concepts are modified in C# from Java, such as polymorphism requiring the virtual keyword, operator overloading restrictions, and switch statements allowing string cases.
3. C# introduces new concepts not in Java like enumerations, foreach loops, properties to encapsulate fields, pointers in unsafe contexts, and passing arguments by reference.
The document provides information about C and C Sharp programming languages. It discusses the history, features, data types, loops, conditional statements, functions, arrays, pointers, object-oriented concepts like inheritance, encapsulation, polymorphism in both the languages. It also highlights some advantages of C Sharp over C like automatic memory management, no need of header files etc.
This document compares features between Java and C# programming languages. It outlines that C# supports features like events, delegates, properties, operator overloading, and pointers that are absent in Java. Meanwhile, Java supports features like checked exceptions and strictfp keyword that are not present in C#. There are also some philosophical differences between the two languages, such as how methods are handled and whether exceptions are checked. Overall, the document provides a detailed overview of similarities and differences between the Java and C# programming languages.
C is a general-purpose high level language that was originally developed by Dennis Ritchie for the Unix operating system. It was first implemented on the Digital Equipment Corporation PDP-11 computer in 1972.
The document provides an overview of C++ vs C# by Shubhra Chauhan. It discusses the key object-oriented programming concepts like classes, objects, inheritance, polymorphism, and how they are implemented in C++ and C#. It includes code examples to demonstrate class usage and inheritance in both languages. The document also compares some similarities and differences between C++ and C# like support for pointers, preprocessors, structures, and goto statements.
C++ and C# are compared, with key differences noted such as C++ compiling to machine code while C# compiles to CLR. An algorithm to calculate rectangle area is presented, with programs in C++ and C# provided as examples. The conclusion states that C# is better than C++ in performance, usability and durability due to features like automatic memory management that C# has which C++ lacks.
This document provides an overview and structure of a course on advanced C language for engineering. It discusses topics that will be covered including the FILE methodology, literate programming with cweb tools, classes for embedded systems, and using C with Lex and YACC for linguistic support. The document outlines the overall structure of the course and provides examples to introduce fundamental C concepts like variables, data types, loops, conditional statements, and functions.
Complete C++ programming Language CourseVivek chan
This document provides an overview of topics covered in a C++ programming course, including:
- Introduction to C++ language fundamentals like data types, variables, operators, control structures, functions, and classes
- Memory concepts, arithmetic, decision making, and algorithms
- Structured and object-oriented programming principles
- The basics of the C++ environment like compilers, linkers, and input/output streams
- Common library functions and concepts like headers, prototypes, and enumerations
The document serves as an introductory reference for anyone learning C++ or wanting to understand the basic building blocks of the language.
This document contains 10 questions and answers about various C language concepts:
1. C was developed between 1969-1973 at Bell Labs by Dennis Ritchie, aimed for use with UNIX OS. It is widely used for application and system software development.
2. A static variable in C is declared inside a function but its value is retained between function calls.
3. A normal variable stores a value that can change, while a pointer defines the address of another variable rather than storing a value itself.
The document provides an overview of Microsoft Visual C# and C# basics. It covers topics like getting started with a first C# program, data types, operators, control statements, namespaces, objects and types, methods, classes, structs, inheritance, interfaces, polymorphism, arrays, generics, collections, memory management, attributes, exceptions and more. It also discusses C# compiler options, console I/O formatting, comments, and directives.
The document is a lecture on C programming given on August 17th, 2008 at IIT Kanpur by Deepak Majeti. It covers basics of C including data types, operators, input/output functions, and provides examples of simple C programs. It also discusses compilation, debugging errors, and homework problems involving operator precedence.
The document provides an overview of C# and .NET concepts including:
- C# versions from 1.0 to 5.0 and new features introduced in each version such as generics, LINQ, lambda expressions etc.
- .NET Framework concepts such as Common Language Runtime (CLR), Just-In-Time (JIT) compilation, garbage collection.
- Value types vs reference types, stack vs heap memory.
- Language Integrated Query (LINQ) and expression trees.
- Various C# language concepts are demonstrated through code examples.
C++ programming language basic to advance levelsajjad ali khan
C/C++ is a procedural programming language developed in the 1970s. C++ builds on C and adds object-oriented programming capabilities. Some key differences between C and C++ include C++ supporting classes, function overloading, and operator overloading. C++ is commonly used to create operating systems, compilers, databases, games, and other application software. The document then discusses C++ history, creators, uses, data types, variables, operators, control flow statements like if/else and loops, arrays, and multi-dimensional arrays. It provides examples of C++ code and basics of the C++ programming language.
This document provides an introduction to the C programming language. It covers C program structure, variables, expressions, operators, input/output, loops, decision making statements, arrays, strings, functions, pointers, structures, unions, file input/output and dynamic memory allocation. The document uses examples and explanations to introduce basic C syntax and concepts.
The document outlines the course content for a C++ introductory course, including introductions to OOP concepts like classes and objects, pointers, functions, inheritance, and polymorphism. It also covers basic C++ programming concepts like I/O, data types, operators, and data structures. The course aims to provide students with fundamental C++ programming skills through explanations and examples of key C++ features.
This document provides an overview of C++ programming concepts including:
1. C++ programs consist of functions, with every program containing a main() function. Functions contain declarations, statements, comments, and can call libraries.
2. Variables must be declared with a type and can be used to store values. C++ supports integer, floating point, character, and other variable types.
3. C++ allows selection and decision making using if/else statements, switch statements, logical operators, and loops like while and for. Operators allow comparisons and boolean evaluations.
Programming is hard. Programming correct C and C++ is particularly hard. Indeed, both in C and certainly in C++, it is uncommon to see a screenful containing only well defined and conforming code.Why do professional programmers write code like this? Because most programmers do not have a deep understanding of the language they are using.While they sometimes know that certain things are undefined or unspecified, they often do not know why it is so. In these slides we will study small code snippets in C and C++, and use them to discuss the fundamental building blocks, limitations and underlying design philosophies of these wonderful but dangerous programming languages.
This content has a CC license. Feel free to use it for whatever you want. You may download the original PDF file from: http://www.pvv.org/~oma/DeepC_slides_oct2012.pdf
This presentation comes with many additional notes (pdf): http://de.slideshare.net/nicolayludwig/2-c-sharp-introductionbasicsparti-38639098
- A Tour through other .Net Programming Languages
- C# Syntax Cornerstones
The document discusses inheritance in C# through an example program. The Child class inherits from the Parent class and overrides the print() method. When an instance of the Child class is created, it first calls the Parent class constructor through the base keyword, then the Child constructor is called. When print() is called on the Child instance, it first calls the base print() method from the Parent class, then calls the Child's print() method.
C is a procedural programming language. It was developed in the early 1970s and is still widely used. The document provides an overview of key aspects of C including data types, variables, constants, operators, control statements like if/else, and functions. It also discusses C programming concepts like low-level vs high-level languages, header files, comments, escape sequences, and more. The document serves as a useful introduction and reference for someone learning the basics of the C programming language.
The Common Language Runtime (CLR) is the virtual machine component of Microsoft's .NET framework that manages the execution of .NET programs. It provides services like memory management, type safety, exception handling, garbage collection, security, and thread management. The CLR converts compiled code into machine instructions using just-in-time compilation. All .NET framework programs, regardless of programming language, are executed by the CLR. There are four main components of the .NET Framework: the CLR, Common Type System (CTS), Base Class Library (BCL), and Common Language Specification (CLS).
This document provides an overview of C++ and object-oriented programming concepts. It discusses:
1. C++ is an object-oriented programming language introduced in the 1980s that retains the power of C and adds classes, inheritance, function overloading, and operator overloading.
2. OOP languages like C++ are well-suited for developing large, complex programs like editors, compilers, databases, and communication systems due to features like modularity and code reusability.
3. A simple C++ program is presented that demonstrates basic syntax like main(), comments, cout and << operators, and return type for main(). Classes and member functions are also introduced.
C++ is an object-oriented programming language developed by Bjarne Stroustrup at AT&T Bell Lab in the year 1980. Initially it was named “C with classes” but later in 1983 the name changed to C++. It is an extension of C with..
This document outlines the basics of C++ programming, including:
- The history and evolution of C++ and other programming languages.
- How a C++ source code is compiled into an executable program by the compiler in multiple steps like preprocessing, compiling, linking etc.
- The structure of a basic C++ program and key elements like main function, headers, comments.
- How to use input/output streams, variables, arithmetic operations, and conditional statements like if-else in a C++ program.
This document provides an overview and outline of a presentation on exploring C++. It begins with background expectations for attendees and then outlines the session topics, which include C++ concepts like templates, exception handling, and an overview of the Standard Template Library and Boost library. The presentation aims to provide a high-level introduction to C++ basics rather than an exhaustive reference. It will cover primary programming paradigms in C++, best practices, and memory management techniques.
An introduction to the C programming language for the students of the course "HJ-82 Ontwerpen voor de optie multimedia en signaalverwerking: seminaries", taught by the authors at the Catholic University of Leuven.
The document provides an overview of C++ polymorphism. Some key points include:
1. Polymorphism allows calling the same method for different types through dynamic binding using virtual functions.
2. Virtual functions in a base class can be overridden in derived classes to change behavior at runtime depending on the object type.
3. Pure virtual functions require derived classes to implement them, making a class abstract. Abstract base classes are useful for defining interfaces.
4. Public inheritance models an "is-a" relationship and allows polymorphism, while private inheritance is mainly for encapsulation.
The document provides an overview of various control statements in Java including if/else statements, switch statements, loops (for, while, do-while), break, continue statements, and nested loops. It includes code examples to demonstrate how to use each control structure and discusses variations like nested if/switch statements, empty loops, and declaring loop variables inside the for statement.
This document provides an overview of the central processing unit (CPU). It discusses that the CPU is referred to as the brain of the computer and contains an arithmetic logic unit (ALU) and control unit (CU). The ALU performs arithmetic and logical operations, while the CU directs other parts of the system. The CPU also includes registers for temporary storage. Communication between the CPU and other components like memory and I/O devices occurs via buses that transfer data, addresses, and control signals. Caches provide faster access to frequently used data and instructions.
This document contains 10 questions and answers about various C language concepts:
1. C was developed between 1969-1973 at Bell Labs by Dennis Ritchie, aimed for use with UNIX OS. It is widely used for application and system software development.
2. A static variable in C is declared inside a function but its value is retained between function calls.
3. A normal variable stores a value that can change, while a pointer defines the address of another variable rather than storing a value itself.
The document provides an overview of Microsoft Visual C# and C# basics. It covers topics like getting started with a first C# program, data types, operators, control statements, namespaces, objects and types, methods, classes, structs, inheritance, interfaces, polymorphism, arrays, generics, collections, memory management, attributes, exceptions and more. It also discusses C# compiler options, console I/O formatting, comments, and directives.
The document is a lecture on C programming given on August 17th, 2008 at IIT Kanpur by Deepak Majeti. It covers basics of C including data types, operators, input/output functions, and provides examples of simple C programs. It also discusses compilation, debugging errors, and homework problems involving operator precedence.
The document provides an overview of C# and .NET concepts including:
- C# versions from 1.0 to 5.0 and new features introduced in each version such as generics, LINQ, lambda expressions etc.
- .NET Framework concepts such as Common Language Runtime (CLR), Just-In-Time (JIT) compilation, garbage collection.
- Value types vs reference types, stack vs heap memory.
- Language Integrated Query (LINQ) and expression trees.
- Various C# language concepts are demonstrated through code examples.
C++ programming language basic to advance levelsajjad ali khan
C/C++ is a procedural programming language developed in the 1970s. C++ builds on C and adds object-oriented programming capabilities. Some key differences between C and C++ include C++ supporting classes, function overloading, and operator overloading. C++ is commonly used to create operating systems, compilers, databases, games, and other application software. The document then discusses C++ history, creators, uses, data types, variables, operators, control flow statements like if/else and loops, arrays, and multi-dimensional arrays. It provides examples of C++ code and basics of the C++ programming language.
This document provides an introduction to the C programming language. It covers C program structure, variables, expressions, operators, input/output, loops, decision making statements, arrays, strings, functions, pointers, structures, unions, file input/output and dynamic memory allocation. The document uses examples and explanations to introduce basic C syntax and concepts.
The document outlines the course content for a C++ introductory course, including introductions to OOP concepts like classes and objects, pointers, functions, inheritance, and polymorphism. It also covers basic C++ programming concepts like I/O, data types, operators, and data structures. The course aims to provide students with fundamental C++ programming skills through explanations and examples of key C++ features.
This document provides an overview of C++ programming concepts including:
1. C++ programs consist of functions, with every program containing a main() function. Functions contain declarations, statements, comments, and can call libraries.
2. Variables must be declared with a type and can be used to store values. C++ supports integer, floating point, character, and other variable types.
3. C++ allows selection and decision making using if/else statements, switch statements, logical operators, and loops like while and for. Operators allow comparisons and boolean evaluations.
Programming is hard. Programming correct C and C++ is particularly hard. Indeed, both in C and certainly in C++, it is uncommon to see a screenful containing only well defined and conforming code.Why do professional programmers write code like this? Because most programmers do not have a deep understanding of the language they are using.While they sometimes know that certain things are undefined or unspecified, they often do not know why it is so. In these slides we will study small code snippets in C and C++, and use them to discuss the fundamental building blocks, limitations and underlying design philosophies of these wonderful but dangerous programming languages.
This content has a CC license. Feel free to use it for whatever you want. You may download the original PDF file from: http://www.pvv.org/~oma/DeepC_slides_oct2012.pdf
This presentation comes with many additional notes (pdf): http://de.slideshare.net/nicolayludwig/2-c-sharp-introductionbasicsparti-38639098
- A Tour through other .Net Programming Languages
- C# Syntax Cornerstones
The document discusses inheritance in C# through an example program. The Child class inherits from the Parent class and overrides the print() method. When an instance of the Child class is created, it first calls the Parent class constructor through the base keyword, then the Child constructor is called. When print() is called on the Child instance, it first calls the base print() method from the Parent class, then calls the Child's print() method.
C is a procedural programming language. It was developed in the early 1970s and is still widely used. The document provides an overview of key aspects of C including data types, variables, constants, operators, control statements like if/else, and functions. It also discusses C programming concepts like low-level vs high-level languages, header files, comments, escape sequences, and more. The document serves as a useful introduction and reference for someone learning the basics of the C programming language.
The Common Language Runtime (CLR) is the virtual machine component of Microsoft's .NET framework that manages the execution of .NET programs. It provides services like memory management, type safety, exception handling, garbage collection, security, and thread management. The CLR converts compiled code into machine instructions using just-in-time compilation. All .NET framework programs, regardless of programming language, are executed by the CLR. There are four main components of the .NET Framework: the CLR, Common Type System (CTS), Base Class Library (BCL), and Common Language Specification (CLS).
This document provides an overview of C++ and object-oriented programming concepts. It discusses:
1. C++ is an object-oriented programming language introduced in the 1980s that retains the power of C and adds classes, inheritance, function overloading, and operator overloading.
2. OOP languages like C++ are well-suited for developing large, complex programs like editors, compilers, databases, and communication systems due to features like modularity and code reusability.
3. A simple C++ program is presented that demonstrates basic syntax like main(), comments, cout and << operators, and return type for main(). Classes and member functions are also introduced.
C++ is an object-oriented programming language developed by Bjarne Stroustrup at AT&T Bell Lab in the year 1980. Initially it was named “C with classes” but later in 1983 the name changed to C++. It is an extension of C with..
This document outlines the basics of C++ programming, including:
- The history and evolution of C++ and other programming languages.
- How a C++ source code is compiled into an executable program by the compiler in multiple steps like preprocessing, compiling, linking etc.
- The structure of a basic C++ program and key elements like main function, headers, comments.
- How to use input/output streams, variables, arithmetic operations, and conditional statements like if-else in a C++ program.
This document provides an overview and outline of a presentation on exploring C++. It begins with background expectations for attendees and then outlines the session topics, which include C++ concepts like templates, exception handling, and an overview of the Standard Template Library and Boost library. The presentation aims to provide a high-level introduction to C++ basics rather than an exhaustive reference. It will cover primary programming paradigms in C++, best practices, and memory management techniques.
An introduction to the C programming language for the students of the course "HJ-82 Ontwerpen voor de optie multimedia en signaalverwerking: seminaries", taught by the authors at the Catholic University of Leuven.
The document provides an overview of C++ polymorphism. Some key points include:
1. Polymorphism allows calling the same method for different types through dynamic binding using virtual functions.
2. Virtual functions in a base class can be overridden in derived classes to change behavior at runtime depending on the object type.
3. Pure virtual functions require derived classes to implement them, making a class abstract. Abstract base classes are useful for defining interfaces.
4. Public inheritance models an "is-a" relationship and allows polymorphism, while private inheritance is mainly for encapsulation.
The document provides an overview of various control statements in Java including if/else statements, switch statements, loops (for, while, do-while), break, continue statements, and nested loops. It includes code examples to demonstrate how to use each control structure and discusses variations like nested if/switch statements, empty loops, and declaring loop variables inside the for statement.
This document provides an overview of the central processing unit (CPU). It discusses that the CPU is referred to as the brain of the computer and contains an arithmetic logic unit (ALU) and control unit (CU). The ALU performs arithmetic and logical operations, while the CU directs other parts of the system. The CPU also includes registers for temporary storage. Communication between the CPU and other components like memory and I/O devices occurs via buses that transfer data, addresses, and control signals. Caches provide faster access to frequently used data and instructions.
This document discusses Java primitive data types and operators. It describes the 8 primitive types in Java - boolean, byte, char, double, float, int, long, short - including their ranges and behaviors. It also covers literals, variables, scopes and lifetimes. For operators, it explains arithmetic, relational, logical, assignment, increment/decrement, shift, and ternary operators. It includes examples to demonstrate the usage of various data types and operators in Java programs.
The exception hierarchy
Exception handling fundamentals
Try and catch
The consequences of an uncaught exception
Using multiple catch statements
Catching subclass exceptions
Nested try blocks
Throwing an exception
Re-throwing an exception
Using finally
Using throws
Java’s built-in exception
Creating exception subclasses
This document discusses Java exception handling. It covers the exception hierarchy, keywords like try, catch, throw, throws and finally. It explains how to handle exceptions, create custom exception subclasses, and Java's built-in exceptions. Exception handling allows programs to define error handling blocks to gracefully handle runtime errors rather than crashing.
A class is a template that defines the form of an object. It specifies both the data and code that will operate on that data. Objects are instances of classes. The data and code that constitute a class are called members or instance variables. A class definition creates a new data type. Objects are created using the new operator, which dynamically allocates memory and returns a reference to the new object. Constructors initialize objects when they are created and can be used to assign initial values to data members. Methods manipulate the data defined by the class and can accept parameters. The garbage collector automatically reclaims memory occupied by objects no longer being used to prevent memory leaks.
This document discusses arrays in Java. It explains that arrays are objects that hold a collection of variables of the same type. It covers how to declare and initialize arrays, including one-dimensional, multi-dimensional, and jagged arrays. The document also discusses various array operations like length, for-each loops, searching, and more. Examples are provided to demonstrate array concepts.
This document discusses packages and interfaces in Java. It covers:
- Packages organize related classes and provide encapsulation. Interfaces define methods without implementation.
- Packages and interfaces give greater control over program organization.
- Classes in a package are accessed through the package name and can control access. Namespaces avoid collisions.
- Interfaces define methods without bodies. Classes implement interfaces by providing method bodies. Interface references allow polymorphism.
- Variables in interfaces are public, static, and final constants available to implementing classes. Interfaces can extend other interfaces.
The document discusses various types of computer output devices. It describes printers such as dot matrix, inkjet, and laser printers. It also mentions plotters, computer output microfilm, monitors, voice response systems, and projectors. It provides details on the functioning and use of different printers and how they produce hard and soft copy output.
The document discusses passing objects to methods in Java. It defines a Block class with dimensions and volume that can be passed to methods to compare blocks. The sameBlock() method returns true if the dimensions match, and sameVolume() returns true if the volumes match. The main method creates Block objects and calls the methods to test equality. This demonstrates how objects can be passed to methods and their properties compared.
Introduction,Developing a Program, Program Development Life Cycle, Algorithm,Flowchart,Flowchart Symbols,Guidelines for Preparing Flowcharts,Benefits and Limitations of Flowcharts
- Java performs I/O through streams which are abstractions that produce or consume data and are linked to physical devices.
- There are two types of streams in Java: byte streams which handle input/output of bytes and character streams which handle input/output of characters more efficiently.
- The main classes for byte streams are InputStream, OutputStream and their subclasses like FileInputStream and FileOutputStream. The main classes for character streams are Reader and Writer.
- The predefined streams System.in, System.out and System.err represent standard input, standard output and standard error streams in Java.
This document provides an overview of the Global System for Mobile Communications (GSM). It discusses key aspects of GSM including its history, standards, architecture, entities, interfaces, addresses and identifiers. The main points are:
- GSM is a cellular network standard used by mobile phones that aims to support international roaming, good call quality, and low terminal/service costs.
- The GSM architecture consists of mobile stations, a base station subsystem, a network switching subsystem, an operations support subsystem, and data infrastructure.
- Key entities include the mobile station, base transceiver station, base station controller, mobile switching center, home location register, and visitor location register.
- GSM
Inheritance allows one class to extend another class, inheriting its attributes and behaviors. The subclass extends the superclass and inherits all of its variables and methods. The subclass can add additional fields and methods. A subclass object can be referenced by a superclass reference variable, allowing polymorphism through method overriding. Abstract classes define methods that subclasses must implement, without providing an implementation itself. The final keyword prevents inheritance or method overriding.
This document describes the architecture for mobile computing. It discusses three tiers: the presentation tier which deals with the user interface; the application tier which handles business logic and transactions; and the data tier which manages database access and storage. It also covers various middleware technologies used to connect these tiers, including message-oriented middleware, transaction processing middleware, and database middleware like ODBC and JDBC. Context-awareness and adapting content to different devices based on context is also discussed.
This document discusses computer memory and the memory hierarchy. It begins by introducing primary and secondary memory. Primary memory, like RAM, is used to process data and instructions directly, while secondary memory, like hard disks, is used for long-term storage. It then describes the memory hierarchy, with internal processor memory and cache at the top for fastest access, primary/RAM memory next, and secondary disk storage at the bottom. The document focuses on RAM, describing its purpose to temporarily store active data and programs, and how it must be refreshed to maintain data in dynamic RAM unlike static RAM.
Multithreaded fundamentals
The thread class and runnable interface
Creating a thread
Creating multiple threads
Determining when a thread ends
Thread priorities
Synchronization
Using synchronized methods
The synchronized statement
Thread communication using notify(), wait() and notifyall()
Suspending , resuming and stopping threads
Importance of I/O devices,Types of input devices,keyboard
Pointing devices,Speech recognition,Digital camera
Webcam,Scanners,OCR,OMR,MICR,Bar-code reader
The document provides an overview of the evolution of computers from ancient counting methods to modern devices. It discusses:
- Early counting methods like fingers, pebbles, and the abacus.
- Mechanical calculating devices developed in the 17th-18th centuries like Pascal's calculator and Leibniz's stepped reckoner.
- Pioneering computer scientists like Babbage, Hollerith, and the development of programmable electromechanical computers.
- The first electronic general purpose computers of the 1940s-50s like ENIAC which used vacuum tubes.
It then summarizes the four generations of computers: 1) Vacuum tube computers of the 1940s-50s
This document compares the programming languages Java and C#. It discusses that C# was developed with the .NET framework in mind and is intended to be the primary language for .NET development. It outlines some subtle syntactic differences between the languages, like how print statements and inheritance are defined. It also examines some concepts that are modified in C# compared to Java, such as polymorphism and operator overloading. Finally, it presents some new concepts in C# that do not exist in Java, including enums, foreach loops, and properties.
C is a general-purpose programming language developed in the 1970s. It has become widely used for systems programming tasks like operating systems or embedded systems. C programs are compiled into machine-readable executable code that can be directly executed by a computer's CPU. Key features of C include modularity through functions, portability across platforms, and high performance due to being close to the hardware level. C programs are made up of functions, variables, expressions, and other elements and are compiled in multiple steps from source code to executable file.
C# programs use namespaces and classes. A class defines methods and variables. C# supports inheritance, interfaces, structs, and enums. The main method runs code. Common data types include primitive types like int and reference types like string. C# can read input, perform math operations, and conditionally execute code using if/else statements. Methods can pass parameters by value or reference.
The document discusses the Objective-C preprocessor and underlying C language features. It covers preprocessor directives like #define, #import, #include, and #undef. It also discusses arrays, structures, pointers, functions, and how Objective-C works with C at a low level. Blocks in Objective-C are described as being similar to functions but having some differences like needing to be declared in .m files instead of .h headers.
Objective-C is an object-oriented programming language based on C. It uses message passing to call methods similarly to Smalltalk. The syntax is based on C with the addition of object-oriented features like classes, inheritance, polymorphism, and dynamic typing. Memory management in Objective-C applications is handled automatically by the compiler through reference counting. Categories allow extending classes at runtime by adding new methods.
The document introduces programming concepts in C++ including:
- The software development cycle of compile, link, and execute source code using an IDE.
- Key programming language elements like keywords, variables, operators, and constructs and how every language has a defined syntax.
- Object-oriented programming concepts in C++ like classes, objects, and inheritance hierarchies.
- A simple "Hello World" C++ program structure and basic data types and output statements.
This document provides a summary of C# versions and new features introduced in C# 7.0, 7.1, 7.2, and 7.3. It discusses features such as binary literals, digit separators, local functions, out variables, tuples, deconstruction, discards, ref returns and locals, pattern matching, expression-bodied members, throw expressions, and more. It also briefly previews some planned features for C# 8.0 like asynchronous streams/sequences, records, ranges, and nullable reference types.
The document provides an overview of Objective-C basics including the Objective-C language, build and runtime, classes, objects, methods, and data encapsulation. It discusses the three main parts of an Objective-C class which are the @interface section for declarations, the @implementation section for definitions, and the program section for problem solving code. Methods are explained as actions performed on class instances that can affect the object's state. The document also covers how to create objects from classes, access methods, and encapsulate data to hide instance variables from direct access.
1 CMPS 12M Introduction to Data Structures Lab La.docxtarifarmarie
1
CMPS 12M
Introduction to Data Structures Lab
Lab Assignment 3
The purpose of this lab assignment is to introduce the C programming language, including standard input-output
functions, command line arguments, File IO, and compilation with Makefiles.
Introduction to C
If you are not already familiar with C (or even if you are) it is recommended that you purchase a good C reference
such as C for Java Programmers: a Primer by Charlie McDowell (Lulu.com 2007). The C programming
language is, in a certain sense, the grandparent of Java (C++ being its parent). Java is known as an Object Oriented
Programming (OOP) language, which means that data structures and the procedures which operate on them are
grouped together into one language construct, namely the class. Common behavior amongst classes is specified
explicitly through the mechanism of inheritance. The C programming language on the other hand does not
directly support OOP, although it can be implemented with some effort. C is known as a procedural programming
language, which means that data structures and functions (i.e. procedures) are separate language constructs. There
are no classes, no objects, and no inheritance. New data types in C are created using the typedef and struct
constructs, which will be illustrated in future lab assignments. There is however much common syntax between
Java and C. Many control structures such as loops (while, do-while, for), and branching (if, if-else, switch) are
virtually identical in the two languages. One major difference is in the way program input and output is handled,
both to and from standard IO devices (keyboard and terminal window), and to and from files. The following is
an example of a "Hello World!" program in C.
Example
/*
* hello.c
* Prints "Hello World!" to stdout
*/
#include <stdio.h>
int main(){
printf("Hello World!\n");
return 0;
}
Comments in C are specified by bracketing them between the strings /* and */, and may span several lines. For
instance /* comment */ or
/* comment
comment */
or
/*
* comment
* comment
*/
are all acceptable. With the right compiler flags, Java/C++ style comments are also acceptable.
// comment
// comment
2
You may use any style you like, but throughout this document we will use the older C style /*comments*/.
Any line beginning with # is known as a preprocessor directive. The preprocessor performs the first phase of
compilation wherein these directives, which are literal text substitutions, are performed, making the program
ready for later stages of compilation. The line #include<stdio.h> inserts the standard library header file
stdio.h, which specifies functions for performing standard input-output operations. Notice that preprocessor
commands in C do not end in a semicolon. One can also specify constant macros using the #define preprocessor
directive as follows.
.
This document discusses object-oriented programming in C#. It begins by explaining the goals of learning C# program structure, comments, data types, and variables. It then provides the basic structure of a C# program and steps to create a graphic user interface project in Visual Studio. Examples are given to add two values and multiply two values by converting textbox inputs to integers, performing calculations, and outputting results. The document also covers comments, C# data types, and methods for converting between data types.
This document provides information on various .NET and C# concepts:
1. It begins with an example C# program that multiplies two numbers and prints the result, demonstrating basic program structure and comments.
2. It then covers identifiers, keywords, single-line and multi-line comments in C#, and the differences between value types and reference types.
3. The document concludes by discussing object-oriented programming concepts in C# like classes, constructors, destructors, methods, inheritance, polymorphism, abstraction, interfaces, and abstract classes.
C is a general-purpose programming language widely used to develop operating systems and compilers. Some key points:
- C was originally developed in the 1970s to write the UNIX operating system and is still commonly used for systems programming.
- It produces very efficient, low-level code and can handle tasks like memory management manually.
- C programs are compiled to machine code before execution. The source code is written in ".c" files and compiled using a C compiler like GCC.
- C supports basic data types like integers, floats, characters, and arrays to organize data in programs. Qualifiers like const can refine variable declarations.
This document provides an introduction to C++ programming using Code::Blocks. It discusses getting started with Code::Blocks on terminals or one's own laptop. The tutorial outline includes a brief history of C++, an introduction to object-oriented programming, when C++ is a good choice, and creating a first "Hello, World" program in Code::Blocks. The document provides an overview of compiling and running a C++ program in Code::Blocks.
This document provides an introduction and overview of C# programming. It discusses that C# is an object-oriented language developed by Microsoft as part of its .NET initiative. The document then covers the structure of a basic C# program, including namespaces, classes, methods, and the required Main method. It also compares C# to C++ and discusses key differences. Finally, it demonstrates how to add comments in C# code and how to use aliases for namespaces.
The document provides an introduction and overview of the C# programming language. It covers topics such as types, expressions, declarations, classes, structs, namespaces, assemblies, attributes, threads, and XML comments. It compares C# to languages like Java and C++, and outlines new features in C# like reference and output parameters, objects on the stack, rectangular arrays, and generics. It also provides a basic "Hello World" example and discusses how C# programs are typically structured across multiple files.
C# is an object-oriented programming language developed by Microsoft that runs on the .NET Framework. The document provides an introduction and overview of C#, including how to write "Hello World" programs in C#, use variables and data types, and add comments. It also discusses C# syntax, the C# development environment, and gives examples of C# code.
This document provides an overview of the C programming language, including its history, uses, basic environment, data types, variables, operators, control structures like if/else statements and loops. It begins with the origins of C in the 1970s and explains that C combines high- and low-level language features, making it useful for systems programming tasks like operating systems and compilers. Examples are provided throughout to illustrate core C concepts like getting user input, performing calculations, and repeating actions with for, while and do-while loops.
C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. It runs on various platforms like Windows, Mac OS, and UNIX. The document provides an overview of key C++ concepts like basic syntax, comments, data types, variables, constants, operators, loops, functions, arrays, strings, pointers, references, structures, classes, inheritance, and input/output. It also lists common functions and their uses.
This document provides an overview of an introductory C# programming course. The course covers C# fundamentals like setting up a development environment, data types, conditionals, loops, object-oriented programming concepts, and data structures. It includes topics like installing Visual Studio, writing a "Hello World" program, built-in data types like string, integer, boolean, and more. The document also outlines sample code solutions for exercises on command line arguments, integer operations, leap year finder, and powers of two.
The document provides an introduction to C programming, including:
- The session objectives are to learn the elements of C programs, variable declarations and data types, operators and expressions, and input/output operations.
- The session topics include an introduction to C programming, the history of C, operators and expressions, and data input/output.
- C is a general purpose programming language invented by Dennis Ritchie in 1972 for implementing operating systems and has since been widely used for other applications as well.
This document contains examples and exercises related to logic and propositions. It introduces topics like propositional logic, truth tables, predicates, quantification, and preconditions/postconditions. Some key points:
- Propositions are statements that can be either true or false. Truth tables can be used to determine the truth value of compound propositions.
- Predicates are statements with variables that can be evaluated as true or false by assigning values to the variables.
- Quantifiers like "for all" (universal) and "there exists" (existential) are used to specify the scope of predicates being true.
- Preconditions and postconditions describe the valid inputs and expected outputs of programs to verify
This document provides an introduction to propositional logic and rules of inference. It defines an argument and valid argument forms. Examples are given to illustrate valid argument forms using propositional variables. Common rules of inference like modus ponens and disjunction introduction are explained. The resolution principle for showing validity of arguments is described. Examples are provided to demonstrate applying rules of inference to build arguments and use resolution to determine validity. The document also discusses fallacies and rules of inference for quantified statements like universal and existential instantiation and generalization.
The document defines logical quantifiers such as existence and uniqueness quantifiers. It discusses how quantifiers can be used to restrict domains and bind variables. It provides examples of translating English statements to logical expressions using quantifiers and discusses precedence, logical equivalences, and negating quantifier expressions.
This document introduces various concepts and methods related to mathematical proofs. It defines key terminology like theorems, propositions, lemmas, corollaries, and conjectures. It also describes different types of proofs like direct proofs, proofs by contraposition, and proofs of equivalence. Examples are provided to illustrate direct proofs for statements about odd integers and perfect squares.
The document discusses verification and validation of simulation models. Verification ensures the conceptual model is accurately represented in the operational model, while validation confirms the model is an accurate representation of the real system. The key steps are: 1) observing the real system, 2) constructing a conceptual model, 3) implementing an operational model. Verification techniques include checking model logic, output reasonableness, and documentation. Validation compares model and system input-output transformations using historical data or Turing tests. The goal is to iteratively modify the model until its behavior sufficiently matches the real system.
The document provides 7 examples of statistical analyses and distributions. Example 1 involves drawing a histogram for discrete vehicle arrival data collected over multiple days. Example 2 involves drawing a histogram for continuous component lifetime data. Example 3 involves estimating parameters and variance for discrete vehicle arrival data. Example 4 involves determining if installation time data follows a normal distribution. Example 5 involves estimating parameters for a lognormal model of investment rate data. Example 6 involves using a chi-square test to determine if discrete vehicle arrival data follows a Poisson distribution. Example 7 involves using a chi-square test to determine if mine injury count data follows a Poisson distribution.
This document provides an overview of input modeling for simulation. It discusses the four main steps: 1) collecting real system data, 2) identifying the probability distribution, 3) estimating distribution parameters, and 4) evaluating goodness of fit. Common distributions are identified like Poisson, normal, exponential. Methods for identifying the distribution include histograms and Q-Q plots. Goodness of fit can be tested using chi-square and Kolmogorov-Smirnov tests. The document also discusses modeling non-stationary processes, selecting distributions without data, and multivariate/time-series input models.
Unit 5 general principles, simulation softwareraksharao
This document discusses concepts and algorithms in discrete-event simulation. It describes key concepts like events, activities, and the event scheduling algorithm. The event scheduling algorithm involves removing the imminent event from the future event list, advancing the clock, executing the event to update the system state, and generating future events. It also discusses world views like event scheduling and activity scanning. The document provides an example of simulating a single-channel queue and how simulation can be implemented in Java and GPSS.
Unit 5 general principles, simulation software problemsraksharao
This document contains instructions for three simulation problems:
1) A grocery store checkout counter simulation until time 21 minutes using an inter-arrival time (IAT) and service time (ST) table.
2) A single channel queue simulation until time 15 using an IAT and ST table and event scheduling algorithm.
3) A dump truck loading and weighing simulation at a mine using random number generation for loading time, weighing time and travel time distributions to estimate loader and scale utilizations.
This document provides an introduction to queuing models and simulation. It discusses key characteristics of queuing systems such as arrival processes, service times, queue discipline, and performance measures. Common queuing notations are also introduced, including the widely used Kendall notation. Examples of queuing systems from various applications are provided to illustrate real-world scenarios that can be modeled using queuing theory.
The document describes examples of queueing and inventory simulation models. It provides examples of simulations of the able-baker queueing model, a dental clinic queue, and inventory systems with probabilistic demand and lead times. For each simulation example, it provides the relevant probability distributions and random numbers used to calculate metrics like average wait times and inventory levels.
Unit 3 random number generation, random-variate generationraksharao
This document discusses random number generation and random variate generation. It covers:
1) Properties of random numbers such as uniformity, independence, maximum density, and maximum period.
2) Techniques for generating pseudo-random numbers such as the linear congruential method and combined linear congruential generators.
3) Tests for random numbers including Kolmogorov-Smirnov, chi-square, and autocorrelation tests.
4) Random variate generation techniques like the inverse transform method, acceptance-rejection technique, and special properties for distributions like normal, lognormal, and Erlang.
This document discusses simulation of queueing systems. It includes key elements like customers, servers, arrival and service processes. It also discusses queue behaviors, disciplines, assumptions made in simulations, and provides examples to simulate grocery store, book stall and dentist clinic queues. The examples show generating random numbers for inter-arrival and service times and calculating metrics like average wait times.
This document provides an introduction and overview of simulation modeling. It discusses when simulation is an appropriate tool, the advantages and disadvantages, common applications, and the basic components and types of systems that can be modeled. It also outlines the typical steps involved in a simulation study, including problem formulation, model building, experimentation and analysis, and documentation. Model building involves conceptualizing the model, collecting data, translating the model into a computer program, verifying that the program is working correctly, and validating the model outputs against real system behavior.
Applet Basics,
Applet Organization and Essential Elements,
The Applet Architecture,
A Complete Applet Skeleton,
Applet Initialization and Termination,
Requesting Repainting
The update() Method,
Using the Status Window
Passing parameters to Applets
The Applet Class
Event Handling The Delegation Event Model
Events,
Using the Delegation Event Model,
More Java Keywords.
This document discusses different types of secondary storage devices, including magnetic tape, magnetic disks, optical disks, and magneto-optical storage devices. It provides details on the structure, organization, and read/write process of various magnetic storage media like magnetic tapes, floppy disks, hard disks, and zip disks. Magnetic tapes provide inexpensive storage but are sequential access devices. Magnetic disks like hard disks enable direct access and are widely used as primary storage.
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTjpsjournal1
The rivalry between prominent international actors for dominance over Central Asia's hydrocarbon
reserves and the ancient silk trade route, along with China's diplomatic endeavours in the area, has been
referred to as the "New Great Game." This research centres on the power struggle, considering
geopolitical, geostrategic, and geoeconomic variables. Topics including trade, political hegemony, oil
politics, and conventional and nontraditional security are all explored and explained by the researcher.
Using Mackinder's Heartland, Spykman Rimland, and Hegemonic Stability theories, examines China's role
in Central Asia. This study adheres to the empirical epistemological method and has taken care of
objectivity. This study analyze primary and secondary research documents critically to elaborate role of
china’s geo economic outreach in central Asian countries and its future prospect. China is thriving in trade,
pipeline politics, and winning states, according to this study, thanks to important instruments like the
Shanghai Cooperation Organisation and the Belt and Road Economic Initiative. According to this study,
China is seeing significant success in commerce, pipeline politics, and gaining influence on other
governments. This success may be attributed to the effective utilisation of key tools such as the Shanghai
Cooperation Organisation and the Belt and Road Economic Initiative.
The CBC machine is a common diagnostic tool used by doctors to measure a patient's red blood cell count, white blood cell count and platelet count. The machine uses a small sample of the patient's blood, which is then placed into special tubes and analyzed. The results of the analysis are then displayed on a screen for the doctor to review. The CBC machine is an important tool for diagnosing various conditions, such as anemia, infection and leukemia. It can also help to monitor a patient's response to treatment.
Software Engineering and Project Management - Introduction, Modeling Concepts...Prakhyath Rai
Introduction, Modeling Concepts and Class Modeling: What is Object orientation? What is OO development? OO Themes; Evidence for usefulness of OO development; OO modeling history. Modeling
as Design technique: Modeling, abstraction, The Three models. Class Modeling: Object and Class Concept, Link and associations concepts, Generalization and Inheritance, A sample class model, Navigation of class models, and UML diagrams
Building the Analysis Models: Requirement Analysis, Analysis Model Approaches, Data modeling Concepts, Object Oriented Analysis, Scenario-Based Modeling, Flow-Oriented Modeling, class Based Modeling, Creating a Behavioral Model.
Advanced control scheme of doubly fed induction generator for wind turbine us...IJECEIAES
This paper describes a speed control device for generating electrical energy on an electricity network based on the doubly fed induction generator (DFIG) used for wind power conversion systems. At first, a double-fed induction generator model was constructed. A control law is formulated to govern the flow of energy between the stator of a DFIG and the energy network using three types of controllers: proportional integral (PI), sliding mode controller (SMC) and second order sliding mode controller (SOSMC). Their different results in terms of power reference tracking, reaction to unexpected speed fluctuations, sensitivity to perturbations, and resilience against machine parameter alterations are compared. MATLAB/Simulink was used to conduct the simulations for the preceding study. Multiple simulations have shown very satisfying results, and the investigations demonstrate the efficacy and power-enhancing capabilities of the suggested control system.
Discover the latest insights on Data Driven Maintenance with our comprehensive webinar presentation. Learn about traditional maintenance challenges, the right approach to utilizing data, and the benefits of adopting a Data Driven Maintenance strategy. Explore real-world examples, industry best practices, and innovative solutions like FMECA and the D3M model. This presentation, led by expert Jules Oudmans, is essential for asset owners looking to optimize their maintenance processes and leverage digital technologies for improved efficiency and performance. Download now to stay ahead in the evolving maintenance landscape.
artificial intelligence and data science contents.pptxGauravCar
What is artificial intelligence? Artificial intelligence is the ability of a computer or computer-controlled robot to perform tasks that are commonly associated with the intellectual processes characteristic of humans, such as the ability to reason.
› ...
Artificial intelligence (AI) | Definitio
1. Unit 4
Book 5- E.Balguruswamy,
Programming in C#, Tata Mc-Graw
Hill, 2nd Edition
1
2. Overview of C#
• Microsoft named their new language as C#, they wanted a better ,
smarter, sharper language than its ancestors C and C++.
• Developed only for .NET platform which provide tools and services that
fully exploit both computing and communication.
• Many features are incorporated from Java.
• Provides one-stop coding approach to maintenance.
• C# is used to develop two categories of programs
– Executable application programs
– Component libraries
• Executable programs are written to carry out certain tasks and require the
method Main in one the classes.
• Component libraries do not require a Main declaration, because they are
stand alone application.
2
4. C# and .net
• C# is a new programming language introduced in.net
• With C# developers can quickly implement applications and
components using built-in capabilities of the .net framework.
• C# code is managed by CLR it becomes safer than C++
• Benefits of CLR
– Interoperability with other languages
– Enhanced security
– Versioning support
– Debugging support
– Automatic garbage collection
– XML support for web based application
4
5. Similarities and differences from JAVA
• C# complier produces an executable code.
• C# has more primitive data types
• C# data types are objects.
• Arrays are declared differently in C#
• Java uses static final to declare a class constant while C# uses
const
• java will have one public class in each file, while c# allows any
file arrangements.
• C# supports the struct type and Java does not.
• C# provides better versioning than java
5
6. • In java parameters are always passed by value, C# allows
parameters to be passed by reference by using ref keyword.
• In java, the switch statement can only have integer
expression, while C# supports either integer or string
expression.
• There is no labeled break statement in C#, goto is used to
achieve this.
• C# uses is operator instead of instanceof operator in Java
• C# allows a variable number of parameters using the params
keywords.
• C# provides fourth type of iteration called foreach.
6
7. A simple C# program
• Displays a line of text.
class sampleone
{
public staic void Main()
{
System.Console.WriteLine(“C# is sharper than C++”);
}
}
7
8. 1. class declaration
– class is object-oriented construct
– class is the keyword and declares a new class.
– sampleone is a C# identifier, specifies the name of the class to be
defined.
2. Braces
– C# is block-structured language, enclosed by braces { and }
– Every class definition begins with ‘{‘ and ends with ‘}’
3. Main
– Must include this method in one of the classes.
– Starting point for executing the program.
– Can have any no. of classes but only one main method
8
9. • Has got keywords public, static , void
• public
– Is an access modifier, tells the C# complier that the main method is
accessible by any one.
• static
– Declares main method is global
– Can be called without creating an instance of the class.
• void
– States that main method does not return any value
9
10. 4. Output line
– System.Console.WriteLine(“C# is sharper than C++”);
– Similar to java statement, printf() of C, cout<< of C++
– Writeline method is a static method of Console class, located in a
namespace System.
– Prints a line C# is sharper than C++
– Every statement in C# should end with a semi-colon
5. Executing the program
– After creating the source code, save with .cs file extension in your
folder in your system. Eg. Sampleone.cs
– For compiling the program, perform csc sampleone.cs
– Executable file(IL code), run by name, sample
10
11. Transformation of source code to output
C# code
IL code
Native machine
code
output
C# compilation
JIT compilation
Execution
(.cs file)
(.exe file)
11
12. Providing interactive input
• Using assignment statement
• Through command line arguments
using System;
class SampleEight
{
public static void Main()
{
Console.Write(“Enter your name”);
String name=Console.ReadLine();
Console.WriteLine(“Hello” +=name);
}
}
12
Output
Enter your name: John
Hello John
13. Using mathematical functions
class SampleNine
{
public static void Main()
{
double x=5.0;
double y;
y=Math.sqrt(x);
Console.WriteLine(“y = “+y);
}
}
13
Output
Y=2.23606
14. Compile time errors
• Real life applications consists of large number of statements
and have complex logic.
• They will have errors in them.
• Two types of errors
– Syntax errors
– Logic errors
• Syntax errors is caught by the complier and logic errors should
be eliminated by testing the program logic carefully.
• When compiler cannot interpret what we want to convey,
result is syntax error.
• Complier detects such an error and displays an appropriate
error message
14
15. //program with syntax errors
using systom; //error
class Sampleten
{
public static void main() //error
{
Console.WriteLine(“y = “+y) //error
}
}
15
16. • The complier could not locate a namespace called “systom”
and therefore produces an error message and then stops
compiling.
• Error message consists of
• Name of the file being complied (error.cs)
• Linenumber and column position of the error (2.7)
• Error code defined by the complier (CS0234)
• Short description about the error.
• Eg: error.cs(2.7):error cs0234: the type or namespace name
‘systom’ does not exist in class or namespace.
16
17. 17
Program structure
Main method section
Documentation section
Using directive section
Interfaces section
Classes section
optional
optional
optional
optional
essential
18. Programming coding style
• C# is freeform language
• No indentation required , so that program works properly.
• But this is bad programming.
• Eg.
Console.WriteLine(“Enter your name”);
• Can be written as
Console.Write
(“Enter your name”);
• Or
Console.Write
(
“Enter your name”
);
18
19. Decision making
• If statement has different forms
– Simple if statement
– if..else statement
– nested if..else statement
– else if ladder
• Switch statement
• ?: operator
19
20. Simple if statement
if (boolean-expression)
{
Statement-block;
}
Statement x;
20
Boolean
expression
Statement block
false
true
entry
Statement x
Next Statement
21. The if..else statement
if (boolean-expression)
{
true-block Statement(s);
}
else
{
false-block statement(s);
}
Statement x;
21
Boolean
expression
True block Statement
true
entry
Statement x
Next Statement
False block Statement
false
25. ?: operator
• Conditional operator
• conditional expression ? expression1:expression2
• Conditional expression is evaluated first
• If result is true, expression 1 is evaluated
• If result is false, expression2 is evaluated
• Eg:
if(x<0)
flag=0;
else
flag=1;
• Can be written as
flag=(x<0)?0:1
25
26. Boxing and unboxing
• Methods are invoked using objects.
• Value types like int and long are not objects , we cannot use
them to call methods.
• Can be achieved using a technique called boxing.
• Boxing means the conversion of value type on the stack to a
object type on the heap.
• Unboxing means conversion of object type back into value
type
26
27. boxing
• When the complier finds a value type where it needs a
reference type, it creates an object ‘box’ into which it places
the value of the value type.
int m=100;
Object om=m; //creates a box to hold m
• On execution, it creates a temporary reference_type ‘box’ to
old the object on heap.
• Boxing operation creates a copy of the value of m integer to
object om.
27
28. unboxing
• Unboxing is the process of converting the object type back to
value type.
• Unboxing is possible only for previously boxed variable.
int m=10;
object om=m; //box m
int n= (int) om;
• When unboxing , c# checks that the value type requested is
actually stored in the object under conversion. Only if it is,
the value is unboxed.
• We should ensure that, the value type is large enough to hold
the value of the object. Otherwise it may result in run-time
error.
28
29. Declaring methods
modifiers type methodname (formal-parameter-list)
{
method_body
}
• Five parts
– Name of the method
– Type of the value the method returns
– List of parameters
– Body of the method
– Method modifiers
29
int product(int x,int y)
{
int m=x*y;
return(m);
}
30. Invoking methods
• The process of activating a
method is known as
invoking or calling.
• Done using dot operator
• objectname.methodname(a
ctual-parameter-list);
• The values of the actual
parameters are assigned to
the formal parameters at
the time of invocation.
using System;
class method
{
int cube(int x)
{
return(x*x*x);
}
}
class methodtest
{
public static void Main()
{
method m=new method();
int y=m.cube(5);
Console.WriteLine(y);
}
}
30
31. Invoking a static method
using System;
class staticmethod
{
public static void Main()
{
double y=square(4);
Console.WriteLine(y);
}
static double square(int x)
{
return(x*x);
}
}
31
32. Pass by value
using System;
class method
{
static void func(int m)
{
m=m+10;
Console.Write(m);
}
}
class methodtest
{
public static void Main()
{
int x=100;
func(x);
Console.WriteLine(x);
}
}
32
33. Pass by reference
• ref keyword is used.
using System;
class passbyref
{
static void swap( ref int x, ref int y)
{
int temp=x;
x=y;
y=temp;
}
public static void Main()
{
int m=100,n=200;
console.writeline(“before swapping:”);
console.writeline(“m=“+m);
console.writeline(“n=“+n);
swap(ref m,ref n);
console.writeline(“after swapping”);
console.writeline(“m=“+m);
console.writeline(“n=“+n);
}
}
33
34. Output parameters
• Using out keyword, to return values to the called functions.
using System;
class staticmethod
{
public static void Main()
{
int m,n;
square(4,out m,int n);
Console.WriteLine(m);
C.W(n);
}
static double square(int x, out int y, out int z)
{
y=x*x;
Z=x*x*x;
}
}
34
35. Variable parameter list
using System;
class params
{
static void parray(params int [] arr)
{
C.W(“array elemets are:”);
foreach(int i in arr)
C.W(“ “ +i);
}
public static void main()
{
int x={11,22,33};
parray(x);
parray();
parray(100,200);
}
}
35
36. Methods overloading
using System;
class overloading
{
public static void main()
{
C.W(volume(10));
C.W(volume(2.5 F,8));
C.W(volume(100L,75,15));
}
static int volume(int x)
{
return (x*x*x); //cube
}
static double volume(float r,int h)
{
return(3.14*r*r*h); //cylinder
}
static long volume( long l,int b,int h)
{
return(l*b*h); //box
}
36
37. Defining a class
class classname
{
[variables declaration;]
[methods declaration;]
}
• Class is user defined data type with a template that serves to
define its properties
• Class is the keyword, classname is the valid C# identifier
• Everything inside [ ] is optional.
37
38. Adding variables
• Data is encapsulated in a class by placing data fields inside
the body of the class definition.
• These variables are called instance variables because they are
created whenever a object of the class of instantiated.
class rectangle
{
int length;
int width;
}
38
39. Adding methods
• A class with only data fields and no methods that operate on that
data has no life.
type methodname (parameter-list)
{
method-body;
}
class rectangle
{
int length;
int width;
public void getdata(int x,int y)
{
length=x;
length=y;
}
}
39
40. Member access modifiers
• Private,Public,Protected,Internal,Protected internal
• By default it is private
class visiblity
{
public int x;
internal int y;
protected double d;
float p; //private by default
}
40
41. Creating objects
• Objects are created in C# using the new operator.
• The new operator creates an object of the specified class and
returns a reference to that object.
• rectangle rect1; //declare
• rec1=new rectangle(); //instantiate
• rectangle()is default constructor of the class.
41
42. Accessing class members
• objectname.variablename;
• objectname.methodname(parameter_list);
• rect1.length=15;
• rect1.width=10;
• Constructors:
• It enables an object to initialize itself when it is created.
• Same name as that of the class.
• Do not have any return type, not even void.
42
43. Overloaded constructors
• Methods have same name,
different parameter list and
different definitions method
overloading.
• Used to perform simple tasks
which requires different types of
parameter list.
• Also known as polymorphism.
• Each parameter list should be
unique.
• rect r1=new rect(10,20);
• rect r2=new rect(10);
class rectangle
{
public int length;
public int width;
public rectangle(int x,int y)
{
length=x; width=y;
}
public rectangle(int x)
{
length=width=x;
}
public int area()
{
return(length*width);
}
}
43
44. Static constructors
• Called before any objects of the class is created.
• Used to assign initial values to static data
members.
class abc{
static abc(){
..
}
..
}
44
45. • Private constructors
– All declarations must be contained in the class
– Creating objects using such classes may be prevented by adding a
private constructor to the class.
• Copy constructors
– Creates an object by copying variables from another object.
• C# does not provide a copy constructor. We have to define.
public item(item item)
{
code=item.code;
price=item.price;
}
• Copy constructor is invoked by instantiating an object of type
Item and passing it object to be copied.
• Item item2=new item(item1);
45
46. deconstructors
• Opposite of constructors.
• Name is same as that of the constructor , preceded by ~.
class fun
{…
~fun(){..}
}
• C# manages the memory dynamically and uses a garbage
collector, executes all deconstructors on exit.
• The process of calling a deconstructors when an object is
reclaimed by the garbage collector is called finalization.
46
48. Nesting of classes
public class outer
{
…. // members of outer class
public class inner
{
….//members of inner class
}
}
48
49. Constant members
• Allows declaration of data fields of a class as constant.
• public const int size=100;
• Member size is initialized 100 during compilation , it cannot
be changed later.
• Any attempt done to assign a value to it, will result in
compilation error.
• Const members are implicitly static.
• public static const int size=100;
• Will produce compile time error, we cannot declare explicitly
using static
49
50. read-only members
• Using readonly modifier, we can set the value of the member
using a constructor method, cannot be modified later.
• Declared as static fields or instance fields.
class numbers
{
public readonly int m;
public static readonly int n;
public numbers(int x)
{ m=x; }
static numbers()
{ n=100; }
}
50
51. properties
• Accessor methods to
access the data members
• Mutator method to set
the value of the data
members
• Drawback:
• We have to code accessor
methods manually
• Uses should remember that
they have to use accessor
methods to work with data
members
using system;
class number
{
private int number;
public int anumber; //property
{
get
return number;
set
number=value;
}
}
class propertytest
{
public void static main()
{
number n=new number();
n.anumber=100;
int m=n.anumber;
Console.WriteLine(“Number=”+m);
}
} 51
52. indexers
• They are location indicators
• Used to access class objects just like accessing elements in array
• Useful when class is container of other classes.
• The indexer takes an index argument and looks like an array
• The indexer is declared using name this.
• Implemented using get and set accessors for the [] operator.
public double this[int idx]
{
get
{ //return desired data }
set
{//set desired data }
}
52
53. Defining an interface
• it contains one or more methods, properties, indexers, events
but none of them are implemented in the interface itself.
interface interface_name
{
member declarations;
}
eg. interface show
{
void display();
}
53
54. Extending an interface
Interface l1
{
….
}
interface l2
{
….
}
interface l3:l2,l1
{
….
}
54
Interface name2:name1
{
members of name2
}
• Eg:
interface addition
{
int add(intx,int y);
}
interface compute:addition
{
int sub(int x, int y);
}
55. Implementing interfaces
class classname :interfacename
{
body of classname
}
• Here classname implements the interfacename
class a:b,l1,l2
{
…
}
• Where B is the base class and l1,l2 are the interfaces
55
56. Abstract class and interfaces
interface a
{
void method();
}
abstract class b:a
{
..
public abstract void method();
}
56
57. Delegates
• Dictionary meaning of “Delegate” means a person acting for
another person.
• In C# it means a method acting for another method.
• It is used to invoke a method that has been encapsulated into
it at time of its creation.
• Has four steps
– Delegate declaration
– Delegate methods definition
– Delegate instantiation
– Delegate invocation
57
58. Delegate declaration
• A delegate declaration defines a class using that
System.Delagate base class.
• Delegate methods are any functions whose signature matches
the delegate signature exactly.
• modifier delegate return-type delegate-name(parameters);
• Delegate may be defined in the following places
– Inside a class
– Outside a class
– As top level object in a namespace.
• Delegates are implicitly sealed.
58
59. Delegate methods
• Methods whose references are encapsulated into a delegate
instance are known as delegate methods or callable entities.
• The signature and return type of the delegate methods must
exactly match the signature and return type of the delegate.
• They do not care
– What type of object the method is being called against.
– Whether the method is static or instance method.
59
60. Delegate instantiation
• New delegate-type(expression)
• Delegate-type is the name of the delegate declared earlier whose
object is to be created.
• Expression must be method name or value of delegate type.
delegate int productdelegate(int x,int y);
class delegate
{
static int product (int a,int b)
return (a*b);
//delegate instantiation
productdelegate p=new productdelegate(product);
}
60
61. Delegate invocation
• delegate_object(parameter_list)
• If the invocation return void, the result is nothing and
therefore it cannot be used as an operand of any operator.
• Eg. delegate(x,y);
• If a method returns a value, then it can be used as an operand
of any operator.
• Eg. double result= delegate(2.56,45.73);
61
62. Events
• An event is a delegate type class member that is used by the
object or class to provide a notification to other objects that
an event has occurred.
• The client object can act on an event by adding an event
handler to the event.
• modifier event type event-name;
• Modifiers can be static,virtual,override,abstarct,sealed.
• Typedelegate.
• Eg: public event EventHandler click;
• EventHandler is a delegate and click is an event.
62