100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Class notes

C# coding notes

Rating
-
Sold
-
Pages
5
Uploaded on
25-01-2022
Written in
2021/2022

This document consists of oop principles such as inheritance, polymorphism and instantiation. It also contains notes on ADO objects and SQL.

Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Course

Document information

Uploaded on
January 25, 2022
Number of pages
5
Written in
2021/2022
Type
Class notes
Professor(s)
Salah
Contains
All classes

Subjects

Content preview

C# Programming
Classes
 A blueprint for a specific object.
 Collection of objects of similar type.
 Model for creating objects.

Objects
 template/blueprint that describes the behaviour/state that an object of its type support
 Instance of a class
 Process of creating an object = instantiation
 Fields are actual variables in your object that stores a particular piece of information.
 The data and the methods are called members of an object.
 Communicate through methods
 Creating an object means allocating memory to store the data of variables temporarily
 State is stored in fields and behaviour is stored in methods
 Classes are the Nouns in your analysis of the problem
 Methods in an class correspond to the Verbs that the noun does
 Properties are the Adjectives that describe the noun

Abstraction
 hide the implementation details and display only essential features of the object
 Once a class has been declared as an Abstract class, it cannot be instantiated; it means the object of that class cannot be
created.




Encapsulation
 variables of a class will be hidden from other classes, and can be accessed only through the methods of their current class
 let’s you control the data and operations within a class that are exposed to other classes
 To encapsulate declare the variables of a class as private
 Fields are like variables because they can be read or set directly, subject to applicable access modifiers
 Properties have get and set accessors, which provide more control on how values are set or returned. (read-write property)
 If you don’t want the user to change the value do not add a set property = read-only
 Property without get accessor = write-only
 Private field = public property (normally)
Eg.
class Person
{
private string name; // field

public string Name // property
{
get { return name; } // get method
set { name = value; } // set method
}
}

, Enumeration
 Special class that represents a group of constants
Eg. class Program
{
Private Gender gender;
{
Public enum Gender
{
Male;
Female;
}
gender = Gender.Female;


Constructors
 special type of method that’s executed when an object is instantiated
 enable the programmer to set default values, limit instantiation, and write code that is flexible and easy to read




Instantiating a class
 objects created at runtime from a class are called instances of that particular class

Inheritance
 allows one to create new classes that reuse, extend and modify the behaviour that is defined in other classes.
 Class whose members are inherited = base class/ parent class
 Class that inherits those members = derived class/ child class
 A derived class can only have one base class
 Derived class is a specialization of the base class
 Derived class gains all the members of the base class except its constructors and destructors
 Derived class can reuse the code in the base class without having to re-implement it.
 Derived class can add more members
 Derived class extends the functionality of the base class
 Eg. public class Circle:Shape (Shape is the base class)
 If you define a constructor in the base or derived class you should do the same in the opposite

Polymorphism
 Occurs when we have many classes related to eachother by inheritance
 Uses the methods from Inheritance to perform different tasks, which allows one to perform a single action in different ways.
 Static polymorphism:
$4.83
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
Saaji

Get to know the seller

Seller avatar
Saaji Teachme2-tutor
Follow You need to be logged in order to follow users or courses
Sold
3
Member since
3 year
Number of followers
3
Documents
5
Last sold
1 year ago

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions