Lecture 4 Overview of Classes, Containers & Generics
|
|
- Evan Harris
- 6 years ago
- Views:
Transcription
1 Lecture 4 Overview of Classes, Containers & Generics
2 What is a Programming Object? An object is an instance of a class. A class is a template for an object. Everything's an object!!! Statements such as these are not all that helpful when we are struggling to understand the basic concepts of object-oriented programming(oop). It is better to look as some examples of objects, such as a textbox, a push-button or some user-defined non-gui object like a carddeck. Each of these objects has properties that can be accessed and sometimes manipulated. Multiple instances can be defined for them, and there can be different characteristics for each instance. hello there... Start A programming object is a collection of data (variables or literal constants) and a set of functions that operate on the data. Programming objects give us the illusion ofmaterialobjectsandcanbeusedtosimplify thetaskofprogramdesign.
3 Life Cycle of an Object Every object has a clearly defined life cycle. Apart from the normal state of "being in use," this life cycle includes two important stages: Construction: When an object is first instantiated it needs to be initialized. This initializaztion is known as construction and is carried out by a constructor function. Destruction: When an object is destroyed, there are often some clean-up tasks to perform, such as freeing memory. This is the job of a destructor function. Note: The actions of the destructor function may not occur immediately, so we cannot rely on this function to release memory when we need it. Later we will look into the use of disposable objects to help manage critical resources.
4 Class Members The methods(functions) and data in a class are called class members. Data Members - Data members are instance members unless they are explicitly designated as static. Static data values are associated with the class as a whole. Each instance of a class has its own copy of an instance data value. Data members can be fields, constants, and events. Function Members - Function members perform some operation on the data members of the class. Function members can be methods, properties, constructors, finalizers, operators, and indexers.
5 Methods Are the standard form for functions and procedures. They may have zero or more arguments, they can be either instance or static, and they may or may not return a data value. public static void SomeMethod() // stuff public int YetAnother(int val) // so something with val return //some integer public static int SomeOther() return // some integer public void OneMore(ref int val) // change the value of val
6 Accessors for Properties & Fields These are sets of functions that can be accessed from the client through dotnotation. Properties can do the same type of things that methods can do, except theyhavetheirownsyntax(e.g.getandset). public string SomeProperty get return // the value of the property set //set the property public string SomeOtherProperty get return // the value
7 Constructors Theconstructorhasthesamenameastheclassanditinitializesdata ordoes whateverisneeded tobedonewhenaclassinstance iscreated. public class TheClassName public TheClassName // stuff to do the construction // other stuff public class AnExample public AnExample() // default constructor stuff public AnExample(int num) // constructor stuff that uses num CupOfCoffee mycup = new CupOfCoffee( ); CupOfCoffee mycup = new CupOfCoffee("Maxwell House - Original",false,true); CupOfCoffee(string coffeebrand, bool cream, bool sugar)
8 Finalizers(Destructors) The finalizer has the same name as the class (preceded by a tilde, ~) and it releasesdata ordoeswhateverisneededto bedonewhenaclassinstanceis disposed. class SampleClass ~SampleClass() // destructor stuff "Destructors are used by the.net Framework to clean up after objects. In general, you don't have to provide code for a destructor method; instead, the default operation works for you." We cannot rely on the destructor to free up resources thatare used by an object instance, as this may be a long time after the last time the object is used. Instead we can create Disposable Objects.
9 Operators Operators are infix functions usually defined by one or two symbols. Examples are =, +, >=,&&,andsoon. InC#wecanoverloadoperatorsforuser-defined datatypes. public double x,y,z; public Vec_3(double x, double y, double z) this.x = x; this.y = y; this.z = z; public Vec_3(Vec_3 rhs) x = rhs.x; y = rhs.y; z = rhs.z; public static Vec_3 operator +(Vec_3 lhs, Vec_3 rhs) Vec_3 result = new Vec_3(lhs); result.x += rhs.x; result.y += rhs.y; result.z += rhs.z; return result;
10 Indexers Indexers are used like index values to gain access into an array, except that they can refer to an object. Instead of creating a name, you use the this keyword, which refers the the current object. public somedatatype this[int index] get // do something return some_value; set //set a value in the class related to index
11 Inheritance There are two types of inheritance, implementation and interface. We will review implementation inheritance first, since it is the more common form of inheritance. In implementation inheritance, a type derives from a base type, taking all the base type's member fields and functions. class ExampleClass : object // stuff these are the same class ExampleClass // same stuff
12 Virtual Methods Declaringamethodasvirtualallowsitto beoveriddenby any classthatisderived from the defining class. Virtual members cannot be private, as this would cause a paradox -- a member cannot be overridden by a derived class and yet be inaccessible from the derived class. class SomeBaseClass public vitual void SomeVirtualMethod() // method stuff
13 Overridding a Virtual Method in a Derived Class class BaseGraphicsClass public virtual void DrawLine() public virtual void DrawPoint() class NewDerivedClass : BaseGraphicsClass public override void DrawPoint() Instances of NewDerivedClass have access to the DrawLine() method as well as the new version of the DrawPoint() method.
14 OOP in Wndows Applications
15
16
17
18
19 There is no Magic namespace ButtonMakerDemo public partial class Form1 : Form public Form1() InitializeComponent(); private void newbutton_click(object sender, System.EventArgs e) ((Button) sender).text = "Clicked!!"; private void button1_click(object sender, EventArgs e) ((Button)sender).Text = "Clicked!"; Button newbutton = new Button(); newbutton.click += new EventHandler(newButton_Click); Controls.Add(newButton);
20 namespace ClassInterfaceDemo public abstract class MyBase Classes and Interfaces Demo internal class MyClass : MyBase public interface IMyBaseInterface public interface IMyBaseInterface2 internal interface IMyInterface : IMyBaseInterface, IMyBaseInterface2 internal sealed class MyComplexClass : MyClass, IMyInterface class Program static void Main(string[] args) MyComplexClass myobj = new MyComplexClass(); Console.WriteLine(myObj.ToString()); Console.ReadKey();
21 The Class Diagram
22 System.Object Methods
23 Collections
24
25
26 Main Program (Animal Array) Console.WriteLine("Create an Array type collection of Animal " + "objects and use it:"); Animal[] animalarray = new Animal[2]; Cow mycow1 = new Cow("Deirdre"); animalarray[0] = mycow1; animalarray[1] = new Chicken("Ken"); foreach (Animal myanimal in animalarray) Console.WriteLine("New 0 object added to Array collection, " + "Name = 1", myanimal.tostring(), myanimal.name); Console.WriteLine("Array collection contains 0 objects.", animalarray.length); animalarray[0].feed(); ((Chicken)animalArray[1]).LayEgg(); Console.WriteLine();
27 Main Program (Animal ArrayList Collection) Console.WriteLine("Create an ArrayList type collection of Animal " + "objects and use it:"); ArrayList animalarraylist = new ArrayList(); Cow mycow2 = new Cow("Hayley"); animalarraylist.add(mycow2); animalarraylist.add(new Chicken("Roy")); foreach (Animal myanimal in animalarraylist) Console.WriteLine("New 0 object added to ArrayList collection," + " Name = 1", myanimal.tostring(), myanimal.name); Console.WriteLine("ArrayList collection contains 0 objects.", animalarraylist.count); ((Animal)animalArrayList[0]).Feed(); ((Chicken)animalArrayList[1]).LayEgg(); Console.WriteLine(); Console.WriteLine("Additional manipulation of ArrayList:"); animalarraylist.removeat(0); ((Animal)animalArrayList[0]).Feed(); animalarraylist.addrange(animalarray); ((Chicken)animalArrayList[2]).LayEgg(); Console.WriteLine("The animal called 0 is at index 1.", mycow1.name, animalarraylist.indexof(mycow1)); mycow1.name = "Janice"; Console.WriteLine("The animal is now called 0.", ((Animal)animalArrayList[1]).Name);
28 Limitations of Arrays
29 ArrayList Collection
30 The foreach Construct
31 Ienumerable is Implicit in foreach
32 C# Iterators alternative definition Iterators in the.net Framework are called "enumerators" and represented by the IEnumerator interface. IEnumerator provides a MoveNext() method, which advances to the next element and indicates whether the end of the collection has been reached; a Current property, to obtain the value of the element currently being pointed at; and an optional Reset() method, to rewind the enumerator back to its initial position. The enumerator initially points to a special value before the first element, so a call to MoveNext() is required to begin iterating. Enumerators are typically obtained by calling the GetEnumerator() method of an object implementing the IEnumerable interface. Container classes typically implement this interface. However, the foreach statement in C# can operate on any object providing such a method, even if it doesn't implement IEnumerable. Both interfaces were expanded into generic versions in.net. The following shows a simple use of iterators in C# : // explicit version IEnumerator<MyType> iter = list.getenumerator(); while (iter.movenext()) Console.WriteLine(iter.Current); // implicit version foreach (MyType value in list) Console.WriteLine(value);
33 The Length& Count Properties
34 Collections Accessibility
35 Other Useful Methods in Collections Class
36 AddRange( )
37 IndexOf( )
38 using System.IO; : : namespace EmpListDemo static class Program static void Main(string[] args) string fname = "empstable.txt"; string txtline; The Generic List<T> loading data from a file List<Employee> Emps = new List<Employee>(); // a generic list of Employee List<Employee> Emps2 = new List<Employee>(); // we will make a copy of Emps // reading employee data from a text file TextReader tr = new StreamReader(fname); do txtline = tr.readline(); if (txtline == "xxx") break; string[] field = txtline.split(','); Emps.Add(new Employee(field[0].Trim(),field[1].Trim(), Convert.ToInt32(field[2]), Convert.ToInt32(field[3]), Convert.ToDouble(field[4]))); while (true); tr.close(); : :
39 Displaying the Contents of the List Emps // display the contents of the list Emps foreach (Employee emp in Emps) Console.WriteLine(" ", emp.firstname, emp.lastname, emp.age, emp.yrsemp, emp.wage); Wade Boggs Robin Banks Jerry Mander Amanda Rekonwith Doug Wells Anita Break Juan Abrew Ben Dover Ilene Dover
40 Making a Copy of a List // we are making a copy of Emps called Emps2 foreach (Employee emp in Emps) Employee emp2 = new Employee(); emp2 = emp; Emps2.Add(emp2); // so why not just assign one list to the other? // Emps2 = Emps; // // because this would not make a separate copy but // rather point both Emps2 and Emps to the same records!
41 The RemoveAll Delegate Method // we "tag" each record that passes our criteria foreach (Employee emp in Emps2) if (emp.age > 39 & emp.yrsemp >= 10) emp.tag = true; // now we remove all records from Emps2 that HAVE NOT // been "tagged" i.e. remove those with emp.tag = false // this construct is implemented using a delegate Emps2.RemoveAll(delegate(Employee emp) return!emp.tag; ); age>39 and yrsemp >= 10 Wade Boggs Amanda Rekonwith Wade Boggs Robin Banks Jerry Mander Amanda Rekonwith Doug Wells Anita Break Juan Abrew Ben Dover Ilene Dover
42 Working with LINQ // this is a LINQ query! var queryresults = from q in Emps where q.lastname.startswith("b") select q; // so what's in queryresults??? // let's take a look Console.WriteLine(); foreach (var q in queryresults) Console.WriteLine(q.FirstName + " " + q.lastname); Wade Boggs Robin Banks Anita Break Wade Boggs Robin Banks Jerry Mander Amanda Rekonwith Doug Wells Anita Break Juan Abrew Ben Dover Ilene Dover
43 Another LINQ Query Example // let's try another example // notice we don't redefine the var queryresults queryresults = from q in Emps where q.age>30 select q; // now what's in queryresults??? Console.WriteLine(); foreach (var q in queryresults) Console.WriteLine(q.FirstName + " " + q.lastname); Console.ReadKey(); Wade Boggs Robin Banks Amanda Rekonwith Doug Wells Juan Abrew Ben Dover Wade Boggs Robin Banks Jerry Mander Amanda Rekonwith Doug Wells Anita Break Juan Abrew Ben Dover Ilene Dover
44 // one more example queryresults = from q in Emps where ((q.age>40 & q.wage<20.0) (q.age<40 & q.wage>25.0)) select q; Wade Boggs Doug Wells Wade Boggs Robin Banks Jerry Mander Amanda Rekonwith Doug Wells Anita Break Juan Abrew Ben Dover Ilene Dover
45 Loading an Array from a Text File using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; namespace LoadArrayFromTextfile class Program static void Main(string[] args) int[,] mat = new int[10,10]; string textline; int k; for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) Console.Write("0 ", mat[i, j]); Console.WriteLine(); Console.ReadKey(); TextReader tr = new StreamReader("sample_01.txt"); for (int i = 0; i < 10; i++) textline = tr.readline(); k = 0; foreach (string str in textline.split(' ')) if (str!= "") mat[i, k] = Convert.ToInt32(str); k += 1; tr.close();
46 Reading and Writing Textfiles List<Employee> Emps = new List<Employee>(); string txtline; TextReader tr = new StreamReader("employees.txt"); do txtline = tr.readline(); if (txtline == "xxx") break; string[] field = txtline.split('\t'); Emps.Add(new Employee(field[0].Trim(), field[1].trim(), Convert.ToInt32(field[2]), Convert.ToInt32(field[3]), Convert.ToDouble(field[4]))); while (true); tr.close();
47 Reading and Writing Text Files continued foreach (Employee emp in Emps) Console.WriteLine("0 1", emp.firstname, emp.lastname); TextWriter tw = new StreamWriter("employees.txt"); foreach (Employee emp in Emps) tw.writeline("0 \t 1 \t 2 \t 3 \t 4", emp.firstname, emp.lastname, emp.age, emp.yrsemp, emp.wage); tw.writeline("xxx"); tw.close();
48 Dealing with Data cut & paste
49 Pasting into Word or PPT Preserves Cells
50 Pasting to a Text Editor Creates Separators e.g. Tabs
51
52
Object-Oriented Programming
Object-Oriented Programming 1. What is object-oriented programming (OOP)? OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object
More informationHierarchical inheritance: Contains one base class and multiple derived classes of the same base class.
1. What is C#? C# (pronounced "C sharp") is a simple, modern, object oriented, and type safe programming language. It will immediately be familiar to C and C++ programmers. C# combines the high productivity
More informationVisual C# 2012 How to Program by Pe ars on Ed uc ati on, Inc. All Ri ght s Re ser ve d.
Visual C# 2012 How to Program 1 99 2-20 14 by Pe ars on Ed uc ati on, Inc. All Ri ght s Re ser ve d. 1992-2014 by Pearson Education, Inc. All 1992-2014 by Pearson Education, Inc. All Although commonly
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 7 : Collections Lecture Contents 2 Why collections? What is a collection? Non-generic collections: Array & ArrayList Stack HashTable
More information3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.
3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.
More informationIndexers.
Indexers Indexers are special type of class members that provide the mechanism by which an object can be indexed like an array. Main use of indexers is to support the creation of specialized array that
More informationCHAPTER 1: INTRODUCING C# 3
INTRODUCTION xix PART I: THE OOP LANGUAGE CHAPTER 1: INTRODUCING C# 3 What Is the.net Framework? 4 What s in the.net Framework? 4 Writing Applications Using the.net Framework 5 What Is C#? 8 Applications
More informationObject Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year
Object Oriented Programming Assistant Lecture Omar Al Khayat 2 nd Year Syllabus Overview of C++ Program Principles of object oriented programming including classes Introduction to Object-Oriented Paradigm:Structures
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 8 : Collections Lecture Contents 2 Why collections? What is a collection? Non-generic collections: Array & ArrayList Stack HashTable
More informationDC69 C# and.net JUN 2015
Solutions Q.2 a. What are the benefits of.net strategy advanced by Microsoft? (6) Microsoft has advanced the.net strategy in order to provide a number of benefits to developers and users. Some of the major
More information02 Features of C#, Part 1. Jerry Nixon Microsoft Developer Evangelist Daren May President & Co-founder, Crank211
02 Features of C#, Part 1 Jerry Nixon Microsoft Developer Evangelist Daren May President & Co-founder, Crank211 Module Overview Constructing Complex Types Object Interfaces and Inheritance Generics Constructing
More informationLearn C# Errata. 3-9 The Nullable Types The Assignment Operators
1 The following pages show errors from the original edition, published in July 2008, corrected in red. Future editions of this book will be printed with these corrections. We apologize for any inconvenience
More information9 A Preview of.net 2.0
473 9 A Preview of.net 2.0 Microsoft.NET is an evolving system that is continuously improved and extended. In late 2003 Microsoft announced.net 2.0 (codename Whidbey) as a major new version of.net; a beta
More informationDuhok Polytechnic University Amedi Technical Institute/ IT Dept. Halkawt Rajab Hussain
Duhok Polytechnic University Amedi Technical Institute/ IT Dept. By Halkawt Rajab Hussain 2016-04-02 Inheritance: Concept of Inheritance. Types of inheritance. Virtual base class method. Interface. 4/1/2017
More informationWhat property of a C# array indicates its allocated size? What keyword in the base class allows a method to be polymorphic?
What property of a C# array indicates its allocated size? a. Size b. Count c. Length What property of a C# array indicates its allocated size? a. Size b. Count c. Length What keyword in the base class
More informationC#.Net. Course Contents. Course contents VT BizTalk. No exam, but laborations
, 1 C#.Net VT 2009 Course Contents C# 6 hp approx. BizTalk 1,5 hp approx. No exam, but laborations Course contents Architecture Visual Studio Syntax Classes Forms Class Libraries Inheritance Other C# essentials
More informationCALCULATOR APPLICATION
CALCULATOR APPLICATION Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
More informationIntroduce C# as Object Oriented programming language. Explain, tokens,
Module 2 98 Assignment 1 Introduce C# as Object Oriented programming language. Explain, tokens, lexicals and control flow constructs. 99 The C# Family Tree C Platform Independence C++ Object Orientation
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 8 : Collections Lecture Contents 2 Why collections? What is a collection? Non-generic collections: Array & ArrayList Stack HashTable
More informationIST311. Advanced Issues in OOP: Inheritance and Polymorphism
IST311 Advanced Issues in OOP: Inheritance and Polymorphism IST311/602 Cleveland State University Prof. Victor Matos Adapted from: Introduction to Java Programming: Comprehensive Version, Eighth Edition
More informationIndustrial Programming
Industrial Programming Lecture 4: C# Objects & Classes Industrial Programming 1 What is an Object Central to the object-oriented programming paradigm is the notion of an object. Objects are the nouns a
More informationWhat is an Object. Industrial Programming. What is a Class (cont'd) What is a Class. Lecture 4: C# Objects & Classes
What is an Object Industrial Programming Lecture 4: C# Objects & Classes Central to the object-oriented programming paradigm is the notion of an object. Objects are the nouns a person called John Objects
More informationDC69 C# &.NET JUNE C# is a simple, modern, object oriented language derived from C++ and Java.
Q.2 a. What is C#? Discuss its features in brief. 1. C# is a simple, modern, object oriented language derived from C++ and Java. 2. It aims to combine the high productivity of Visual Basic and the raw
More informationCourse Syllabus C # Course Title. Who should attend? Course Description
Course Title C # Course Description C # is an elegant and type-safe object-oriented language that enables developers to build a variety of secure and robust applications that run on the.net Framework.
More informationAdvanced Object-Oriented Programming. 11 Features. C# Programming: From Problem Analysis to Program Design. 4th Edition
11 Features Advanced Object-Oriented Programming C# Programming: From Problem Analysis to Program Design C# Programming: From Problem Analysis to Program Design 1 4th Edition Chapter Objectives Learn the
More informationPES INSTITUTE OF TECHNOLOGY (BSC) V MCA, Second IA Test, September 2014
PES INSTITUTE OF TECHNOLOGY (BSC) V MCA, Second IA Test, September 2014 Topics in Enterprise Architectures-II Solution Set Faculty: Jeny Jijo 1) What is Encapsulation? Explain the two ways of enforcing
More informationObject-Oriented Programming in C# (VS 2015)
Object-Oriented Programming in C# (VS 2015) This thorough and comprehensive 5-day course is a practical introduction to programming in C#, utilizing the services provided by.net. This course emphasizes
More informationPrevious C# Releases. C# 3.0 Language Features. C# 3.0 Features. C# 3.0 Orcas. Local Variables. Language Integrated Query 3/23/2007
Previous C# Releases C# 3.0 Language Features C# Programming March 12, 2007 1.0 2001 1.1 2003 2.0 2005 Generics Anonymous methods Iterators with yield Static classes Covariance and contravariance for delegate
More informationObject-Oriented Programming in C# (VS 2012)
Object-Oriented Programming in C# (VS 2012) This thorough and comprehensive course is a practical introduction to programming in C#, utilizing the services provided by.net. This course emphasizes the C#
More informationMicrosoft Visual C# Step by Step. John Sharp
Microsoft Visual C# 2013 Step by Step John Sharp Introduction xix PART I INTRODUCING MICROSOFT VISUAL C# AND MICROSOFT VISUAL STUDIO 2013 Chapter 1 Welcome to C# 3 Beginning programming with the Visual
More informationIntroduction to C# Applications
1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making
More informationC# s A Doddle. Steve Love. ACCU April 2013
C# s A Doddle Steve Love ACCU April 2013 A run through C# (pronounced See Sharp ) is a simple, modern, object-oriented, and type-safe programming language. C# has its roots in the C family of languages,
More informationCS Week 13. Jim Williams, PhD
CS 200 - Week 13 Jim Williams, PhD This Week 1. Team Lab: Instantiable Class 2. BP2 Strategy 3. Lecture: Classes as templates BP2 Strategy 1. M1: 2 of 3 milestone tests didn't require reading a file. 2.
More informationINHERITANCE: EXTENDING CLASSES
INHERITANCE: EXTENDING CLASSES INTRODUCTION TO CODE REUSE In Object Oriented Programming, code reuse is a central feature. In fact, we can reuse the code written in a class in another class by either of
More informationWriting Object Oriented Software with C#
Writing Object Oriented Software with C# C# and OOP C# is designed for the.net Framework The.NET Framework is Object Oriented In C# Your access to the OS is through objects You have the ability to create
More informationQuerying In-Memory Data by Using Query Expressions
Chapter 21 Querying In-Memory Data by Using Query Expressions LINQ (Language Integrated Query) CUSTOMER CID FName Lname Company 1 Ram Kumar CITech 2 Sam Peter HP 3 Anil Kumar EMC 2 4 Anuj Patil Dell 5
More informationChapter 1 Getting Started
Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different
More information1 C# 6.0: Practical Guide 6.0. Practical Guide. By: Mukesh Kumar.
1 C# 6.0: Practical Guide C# 6.0 Practical Guide By: Mukesh Kumar 2 C# 6.0: Practical Guide Disclaimer & Copyright Copyright 2016 by mukeshkumar.net All rights reserved. Share this ebook as it is, don
More informationEEE-425 Programming Languages (2013) 1
2 Namespaces Classes Fields Properties Methods Attributes Events Interfaces (contracts) Methods Properties Events Control Statements if, else, while, for, switch foreach Additional Features Operation Overloading
More informationLearning C# 3.0. Jesse Liberty and Brian MacDonald O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo
Learning C# 3.0 Jesse Liberty and Brian MacDonald O'REILLY Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo Table of Contents Preface xv 1. C# and.net Programming 1 Installing C# Express 2 C# 3.0
More informationString sequence of characters string Unicode Characters immutable they cannot be changed after they have been created.
String A string is basically a sequence of characters A string in C# is an object of type String The string type represents a string of Unicode Characters. String objects are immutable that is they cannot
More informationOOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.
OOPS Viva Questions 1. What is OOPS? OOPS is abbreviated as Object Oriented Programming system in which programs are considered as a collection of objects. Each object is nothing but an instance of a class.
More informationApplied object oriented programming. 4 th lecture
Applied object oriented programming 4 th lecture Today Constructors in depth Class inheritance Interfaces Standard.NET interfaces IComparable IComparer IEquatable IEnumerable ICloneable (and cloning) Kahoot
More informationA Comparison of Visual Basic.NET and C#
Appendix B A Comparison of Visual Basic.NET and C# A NUMBER OF LANGUAGES work with the.net Framework. Microsoft is releasing the following four languages with its Visual Studio.NET product: C#, Visual
More informationCOPYRIGHTED MATERIAL. Contents. Part I: C# Fundamentals 1. Chapter 1: The.NET Framework 3. Chapter 2: Getting Started with Visual Studio
Introduction XXV Part I: C# Fundamentals 1 Chapter 1: The.NET Framework 3 What s the.net Framework? 3 Common Language Runtime 3.NET Framework Class Library 4 Assemblies and the Microsoft Intermediate Language
More informationOBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe
OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++
More informationDuhok Polytechnic University Amedi Technical Institute/ IT Dept. Halkawt Rajab Hussain
Duhok Polytechnic University Amedi Technical Institute/ IT Dept. By Halkawt Rajab Hussain 2016-04-02 Overview. C# program structure. Variables and Constant. Conditional statement (if, if/else, nested if
More informationIntroduction To C#.NET
Introduction To C#.NET Microsoft.Net was formerly known as Next Generation Windows Services(NGWS).It is a completely new platform for developing the next generation of windows/web applications. However
More informationYou can call the project anything you like I will be calling this one project slide show.
C# Tutorial Load all images from a folder Slide Show In this tutorial we will see how to create a C# slide show where you load everything from a single folder and view them through a timer. This exercise
More informationMicrosoft Visual Basic 2005: Reloaded
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 10 Creating Classes and Objects Objectives After studying this chapter, you should be able to: Define a class Instantiate an object from a class
More informationMicrosoft. Microsoft Visual C# Step by Step. John Sharp
Microsoft Microsoft Visual C#- 2010 Step by Step John Sharp Table of Contents Acknowledgments Introduction xvii xix Part I Introducing Microsoft Visual C# and Microsoft Visual Studio 2010 1 Welcome to
More informationCourse Hours
Programming the.net Framework 4.0/4.5 with C# 5.0 Course 70240 40 Hours Microsoft's.NET Framework presents developers with unprecedented opportunities. From 'geoscalable' web applications to desktop and
More informationDuhok Polytechnic University Amedi Technical Institute/ IT Dept. Halkawt Rajab Hussain
Duhok Polytechnic University Amedi Technical Institute/ IT Dept. By Halkawt Rajab Hussain 2016-04-02 Objects and classes: Basics of object and class in C#. Private and public members and protected. Static
More informationinside: THE MAGAZINE OF USENIX & SAGE August 2003 volume 28 number 4 PROGRAMMING McCluskey: Working with C# Classes
THE MAGAZINE OF USENIX & SAGE August 2003 volume 28 number 4 inside: PROGRAMMING McCluskey: Working with C# Classes & The Advanced Computing Systems Association & The System Administrators Guild working
More informationUNIT 2. .NET Languages. C# Language Fundamentals. Operators, Types, and Variables. Variables and Types
.NET Languages C# Language Fundamentals Operators, Types, and Variables Variables and Types "Variables" are simply storage locations for data. You can place data into them and retrieve their contents as
More informationLab - 1. Solution : 1. // Building a Simple Console Application. class HelloCsharp. static void Main() System.Console.WriteLine ("Hello from C#.
Lab - 1 Solution : 1 // Building a Simple Console Application class HelloCsharp static void Main() System.Console.WriteLine ("Hello from C#."); Solution: 2 & 3 // Building a WPF Application // Verifying
More informationEEE-425 Programming Languages (2013) 1
2 Learn about class concepts How to create a class from which objects can be instantiated Learn about instance variables and methods How to declare objects How to organize your classes Learn about public
More informationObject Oriented Programming in C#
Introduction to Object Oriented Programming in C# Class and Object 1 You will be able to: Objectives 1. Write a simple class definition in C#. 2. Control access to the methods and data in a class. 3. Create
More informationRules and syntax for inheritance. The boring stuff
Rules and syntax for inheritance The boring stuff The compiler adds a call to super() Unless you explicitly call the constructor of the superclass, using super(), the compiler will add such a call for
More information9 Working with the Java Class Library
9 Working with the Java Class Library 1 Objectives At the end of the lesson, the student should be able to: Explain object-oriented programming and some of its concepts Differentiate between classes and
More informationComputer Science II (20073) Week 1: Review and Inheritance
Computer Science II 4003-232-01 (20073) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Hardware and Software Hardware Physical devices in a computer system
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More information.Net Technologies. Components of.net Framework
.Net Technologies Components of.net Framework There are many articles are available in the web on this topic; I just want to add one more article over the web by explaining Components of.net Framework.
More informationWWW.STUDENTSFOCUS.COM Unit II OBJECT ORIENTED ASPECTS OF C# Key Concepts of Object Orientation Abstraction Encapsulation Polymorphism Inheritance. Abstraction is the ability to generalize an object as
More informationDAD Lab. 1 Introduc7on to C#
DAD 2017-18 Lab. 1 Introduc7on to C# Summary 1..NET Framework Architecture 2. C# Language Syntax C# vs. Java vs C++ 3. IDE: MS Visual Studio Tools Console and WinForm Applica7ons 1..NET Framework Introduc7on
More informationCS304 Object Oriented Programming Final Term
1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes? Generalization (pg 29) Sub-typing
More informationOverview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017
Overview of OOP Dr. Zhang COSC 1436 Summer, 2017 7/18/2017 Review Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in square brackets: l = [1, 2, "a"] (access by index, is mutable
More informationPassing arguments to functions by. const member functions const arguments to a function. Function overloading and overriding Templates
Lecture-4 Inheritance review. Polymorphism Virtual functions Abstract classes Passing arguments to functions by Value, pointers, refrence const member functions const arguments to a function Function overloading
More informationFramework Fundamentals
Questions Framework Fundamentals 1. Which of the following are value types? (Choose all that apply.) A. Decimal B. String C. System.Drawing.Point D. Integer 2. Which is the correct declaration for a nullable
More informationJava. Classes 3/3/2014. Summary: Chapters 1 to 10. Java (2)
Summary: Chapters 1 to 10 Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The University of Texas at Arlington, Arlington, TX 76019 Email: sharma@cse.uta.edu
More informationObject-Oriented Principles and Practice / C++
Object-Oriented Principles and Practice / C++ Alice E. Fischer June 3, 2013 OOPP / C++ Lecture 9... 1/40 Const Qualifiers Operator Extensions Polymorphism Abstract Classes Linear Data Structure Demo Ordered
More informationChapter 12. OOP: Creating Object- Oriented Programs. McGraw-Hill. Copyright 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.
Chapter 12 OOP: Creating Object- Oriented Programs McGraw-Hill Copyright 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. Objectives (1 of 2) Use object-oriented terminology correctly. Create
More informationDistributed Real-Time Control Systems. Lecture 14 Intro to C++ Part III
Distributed Real-Time Control Systems Lecture 14 Intro to C++ Part III 1 Class Hierarchies The human brain is very efficient in finding common properties to different entities and classify them according
More informationC#: advanced object-oriented features
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer C#: advanced object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Namespaces
More informationAdvanced C++ Topics. Alexander Warg, 2017
www.kernkonzept.com Advanced C++ Topics Alexander Warg, 2017 M I C R O K E R N E L M A D E I N G E R M A N Y Overview WHAT IS BEHIND C++ Language Magics Object Life Time Object Memory Layout INTRODUCTION
More informationGame Engineering: 2D
Game Engineering: 2D CS420-2010F-02 Intro to CSharp David Galles Department of Computer Science University of San Francisco 02-0: C++ v. Java We will be coding in C# for this class Java is very similar
More informationChapter 12: How to Create and Use Classes
CIS 260 C# Chapter 12: How to Create and Use Classes 1. An Introduction to Classes 1.1. How classes can be used to structure an application A class is a template to define objects with their properties
More information204111: Computer and Programming
204111: Computer and Programming Week 4: Control Structures t Monchai Sopitkamon, Ph.D. Overview Types of control structures Using selection structure Using repetition structure Types of control ol structures
More informationAdvanced Programming C# Lecture 7. dr inż. Małgorzata Janik
Advanced Programming C# Lecture 7 dr inż. Małgorzata Janik majanik@if.pw.edu.pl Winter Semester 2017/2018 C#: classes & objects 3 / 39 Class members Constructors Destructors Fields Methods Properties Indexers
More informationAdvanced Programming C# Lecture 7. dr inż. Małgorzata Janik
Advanced Programming C# Lecture 7 dr inż. Małgorzata Janik malgorzata.janik@pw.edu.pl Winter Semester 2018/2019 C#: classes & objects 3 / 34 Class members Constructors Destructors Fields Methods Properties
More informationAn Introduction to C++
An Introduction to C++ Introduction to C++ C++ classes C++ class details To create a complex type in C In the.h file Define structs to store data Declare function prototypes The.h file serves as the interface
More informationObject Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming
Overview of OOP Object Oriented Programming is a programming method that combines: a) Data b) Instructions for processing that data into a self-sufficient object that can be used within a program or in
More informationIT 528 Developing.NET Applications Using C# Gülşen Demiröz
IT 528 Developing.NET Applications Using C# Gülşen Demiröz Summary of the Course Hands-on applications programming course We will learn how to develop applications using the C# programming language on
More information3. Basic Concepts. 3.1 Application Startup
3.1 Application Startup An assembly that has an entry point is called an application. When an application runs, a new application domain is created. Several different instantiations of an application may
More informationComputing is about Data Processing (or "number crunching") Object Oriented Programming is about Cooperating Objects
Computing is about Data Processing (or "number crunching") Object Oriented Programming is about Cooperating Objects C# is fully object-oriented: Everything is an Object: Simple Types, User-Defined Types,
More informationAdvanced Programming C# Lecture 2. dr inż. Małgorzata Janik
Advanced Programming C# Lecture 2 dr inż. Małgorzata Janik majanik@if.pw.edu.pl Winter Semester 2017/2018 C# Classes, Properties, Controls Constructions of Note using namespace like import in Java: bring
More informationStart Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK.
Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK. Before you start - download the game assets from above or on MOOICT.COM to
More informationDuhok Polytechnic University Amedi Technical Institute/ IT Dept. Halkawt Rajab Hussain
Duhok Polytechnic University Amedi Technical Institute/ IT Dept. By Halkawt Rajab Hussain 2016-04-02 Pointers: Pointer declaration and initialization. Pointer To Pointer. Arithmetic operation on pointer
More informationData Structures (list, dictionary, tuples, sets, strings)
Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access
More informationImplementing Subprograms
Implementing Subprograms 1 Topics The General Semantics of Calls and Returns Implementing Simple Subprograms Implementing Subprograms with Stack-Dynamic Local Variables Nested Subprograms Blocks Implementing
More informationAN OVERVIEW OF C++ 1
AN OVERVIEW OF C++ 1 OBJECTIVES Introduction What is object-oriented programming? Two versions of C++ C++ console I/O C++ comments Classes: A first look Some differences between C and C++ Introducing function
More informationLecture 18 Tao Wang 1
Lecture 18 Tao Wang 1 Abstract Data Types in C++ (Classes) A procedural program consists of one or more algorithms that have been written in computerreadable language Input and display of program output
More informationAP CS Unit 6: Inheritance Notes
AP CS Unit 6: Inheritance Notes Inheritance is an important feature of object-oriented languages. It allows the designer to create a new class based on another class. The new class inherits everything
More informationThis tutorial has been prepared for the beginners to help them understand basics of c# Programming.
About thetutorial C# is a simple, modern, general-purpose, object-oriented programming language developed by Microsoft within its.net initiative led by Anders Hejlsberg. This tutorial covers basic C# programming
More informationNow find the button component in the tool box. [if toolbox isn't present click VIEW on the top and click toolbox]
C# Tutorial - Create a Tic Tac Toe game with Working AI This project will be created in Visual Studio 2010 however you can use any version of Visual Studio to follow along this tutorial. To start open
More informationHow to be a C# ninja in 10 easy steps. Benjamin Day
How to be a C# ninja in 10 easy steps Benjamin Day Benjamin Day Consultant, Coach, Trainer Scrum.org Classes Professional Scrum Developer (PSD) Professional Scrum Foundations (PSF) TechEd, VSLive, DevTeach,
More informationVisual Basic/C# Programming (330)
Page 1 of 12 Visual Basic/C# Programming (330) REGIONAL 2017 Production Portion: Program 1: Calendar Analysis (400 points) TOTAL POINTS (400 points) Judge/Graders: Please double check and verify all scores
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationPrerequisites: The student should have programming experience in a high-level language. ITCourseware, LLC Page 1. Object-Oriented Programming in C#
Microsoft s.net is a revolutionary advance in programming technology that greatly simplifies application development and is a good match for the emerging paradigm of Web-based services, as opposed to proprietary
More informationSTRUCTURING OF PROGRAM
Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the
More information