Sunteți pe pagina 1din 5

.

Net Framework
Software Framework

Two pieces of it
CLR n FCL

CLR: Common Language Run time


it is Execution environment for dot net applications
It manage your applications when it runs

(SHOLM)
Memory Management
Security
OS and HW independence
Language Independence

FCL or BCL: Framework Class Library or Base


A library of functionality to build applications
WPF, ASP.net, WCF

C#: Standardized language to create dot net components


Syntax similar to java n C++

Visual Studio:
IDE: goal of an IDE to put all tools and functionality that u need to build application
in one place

Edit C# and other files


Runs C# Compiler
Debugging
Testing

Namespace: Organize types


Avoid type name collision

Fully qualified name


Includes assembly name, include namespace name, includes type name

Statement:
Statement is an instruction
Method is a series of statements
Statement end with semicolons
Statements are executed in the order they appear

Expressions:
Expressions are statements that produce a value

Int x=5;

Operators: CERMA

Mathematical Operators: ( +, -, x, /)
Relational: (<, >, <=, >=)
Equality: (= =, ! =)
Conditional: (&&, 11)
Assignment: (=, +=, -=, x=, /=)

References: Allow you to use types in other assemblies


Reference other assemblies in the solution
Reference 3rd party assemblies

Object browser is also used to see what’s inside the assemblies

Constructor:
Special method to create objects
Set default values
Multiple constructors allowed but overload methods must take different arguments

Object Oriented Programming OOPS: PIE

Three primary Concepts PIE

Inheritance
Encapsulation
Polymorphism

Inheritance: create classes to extend or reuse other classes


All classed by default inherit from System.Object

Encapsulation
Access Modifier: AM are keywords that allow you to achieve encapsulation

PPP(public, private, protected) PI(protected internal) I (Internal)

Keyword Applicable to Manning


Public Member, Class No restrictions
Protected Member Access limited to the class n derive classes
Internal (c# default Member, Class Access limited to the current assembly
class AM)
Protected Internal Member Access limited to the current assembly n
derived type
Private(C# def Member Access limited to class
member AM)
Abstract:
Can apply to class and members (methods, properties, events, indexers)
Abstract class can not be instantiated (means can’t use new operator to create objects)
Abstract class is designed as a base class
Abstract class can provide implementation of it s member inside abstract class

Virtual Keyword: Virtual Keyword allow you to achieve polymorphism in C#

Static
Static class can have only static members. Can’t instantiate a static class

Sealed:
Sealed classes can’t be instantiated. Prevent extensibility or misuse#
Some framework classes are sealed for performance and security implications

Public class MyString : System.string


{ // error
}

Method Parameters
Parameters pass by value
Reference types pass a copy of the reference
Value types pass a copy of the value

Parameter keywords
Ref (we are going to used it inside method) and out keywords allow pass “by
reference”

Boxing & Unboxing


Boxing:
Boxing convert vale type to object. It is done implicitly. Performance and memory
consumption problems

Unboxing: convert object to the value type

Enumeration:
A set of named constants. Integer is default data type. By default number starts from
zero.

Value Type & Reference Types


Value Type (SEP)
Enumumration
Structures
Primitive data type

Reference Type (ACID):


Class
Array
Interface
Delegate

Interfaces:
An interface defines group of related methods, properties, and events
No implementation defined in interface
All members are public
Classes and structures can inherited from interface and provide implementation
Classes and structures can inherit from multiple interfaces

Members
Methods:
Methods define behaviour
Every method has zero or more parameters
Use params keyword to accept a variable number of parameters(if u don’t know no of
parameters)
Every method has signature( method name + parameters)

Methods overloading:
Define multiple methods with the same name but a unique signature

Fields:
Fields are variable of a class

Read only fields can assign a value in declaration or in a constructor

Properties: like field but do not denote a storage location

Delegates:
A delegate is a type that references methods
Similar to a function pointer, but type safe

Subscribing to events:
Use += and -= to attach or detach events handlers

This keyword:
This always represent the current instance of the class

Static properties and static method always invoked through type name.
Instance method and properties are invoked through object instance.

Indexers:
Enables indexing of an object(like an array)

Operator overloading
We can overload most unary and binary operators
+ - * / ++ -- = = <>
Overload using static methods

Conversion Operator
Convert an object from one type to another
implicit or explicit( cast type) conversion operator

Destructor:
Destructor is used to clean up an object instance
Can not overload class destructor
Can not explicitly invoked destructor

Used destructor to release unmanaged resources

C Sharp Flow
If Statement

If statement selects a statement for execution based on some provided Boolean value

Conditional operator or ternary operator

String pass = age > 20 ? “pass” : “nopass”

Switching

Restricted to integers, string, enum, characters


Case labels are constants
Default label is optional

S-ar putea să vă placă și