A presentation I gave in Expert Days 2012. In this presentations I explain how most of the features in the C# language work, including Iterators, Lambdas, Linq, Dynamics, and more.
Collections and its types in C# (with examples)Aijaz Ali Abro
Learn step by step c# collections with easy examples. Learn generic, non-generic and specialized collections along with easy and great examples. Learn about arraylist, queue class,stack class and more. Difference between generic and non-generic collections. Difference between arraylist and simple array.
A presentation I gave in Expert Days 2012. In this presentations I explain how most of the features in the C# language work, including Iterators, Lambdas, Linq, Dynamics, and more.
Collections and its types in C# (with examples)Aijaz Ali Abro
Learn step by step c# collections with easy examples. Learn generic, non-generic and specialized collections along with easy and great examples. Learn about arraylist, queue class,stack class and more. Difference between generic and non-generic collections. Difference between arraylist and simple array.
A method is a code block that contains a series of statements. A program causes the statements to be executed by calling the method and specifying any required method arguments. In C#, every executed instruction is performed in the context of a method.
This lecture/presentation cover topic such as C# Introduction, History, The C# Programming Language, The Microsoft .NET Framework, Why C#?, Types of Application, and SharpDevelop 5.1.x
A method is a code block that contains a series of statements. A program causes the statements to be executed by calling the method and specifying any required method arguments. In C#, every executed instruction is performed in the context of a method.
This lecture/presentation cover topic such as C# Introduction, History, The C# Programming Language, The Microsoft .NET Framework, Why C#?, Types of Application, and SharpDevelop 5.1.x
Esoft Metro Campus - Diploma in Information Technology - (Module IX) Programming with C#.NET
(Template - Virtusa Corporate)
Contents:
Introduction to .NET Framework
.NET Framework Platform Architecture
Microsoft Visual Studio
C# Language
C#, VS and .NET Framework Versions
Your First C# Application
Printing Statements
Comments in C#
Common Type System
Value Types and Reference Type
Variables Declaration in C#
Type Conversion
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
If Statement
If… Else Statement
If… Else if… Else Statement
Nested If Statement
Switch Statement
While Loop
Do While Loop
For Loop
Arrays
Accessing Arrays using foreach Loop
Two Dimensional Arrays
Classes and Objects in C#
Inheritance in C#
Partial Classes
Namespaces
Windows Forms Applications
Using Buttons, Labels and Text Boxes
Displaying Message Boxes
Error Handling with Try… Catch… finally…
Using Radio Buttons
Using Check Boxes
Using List Boxes
Creating Menus
Creating ToolStrips
MDI Forms
Database Application in C#
Creating a Simple Database Application
SQL Insert / Update / Retrieving / Delete
SQL Command Execute Methods
Data Sets
ESOFT Metro Campus - Diploma in Software Engineering - (Module V) Windows Based Application Development in C#
(Template - Virtusa Corporate)
Contents:
Introduction to .NET Framework
.NET Framework Platform Architecture
Microsoft Visual Studio
C# Language
C#, VS and .NET Framework Versions
Your First C# Application
Printing Statements
Comments in C#
Common Type System
Value Types and Reference Type
Variables Declaration in C#
Type Conversion
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
If Statement
If… Else Statement
If… Else if… Else Statement
Nested If Statement
Switch Statement
While Loop
Do While Loop
For Loop
Arrays
Accessing Arrays using foreach Loop
Two Dimensional Arrays
Classes and Objects in C#
Inheritance in C#
Partial Classes
Namespaces
Windows Forms Applications
Using Buttons, Labels and Text Boxes
Displaying Message Boxes
Error Handling with Try… Catch… finally…
Using Radio Buttons
Using Check Boxes
Using List Boxes
Creating Menus
Creating ToolStrips
MDI Forms
Database Application in C#
Creating a Simple Database Application
SQL Insert / Update / Retrieving / Delete
SQL Command Execute Methods
Data Sets
Esoft Metro Campus - Certificate in c / c++ programmingRasan Samarasinghe
Esoft Metro Campus - Certificate in java basics
(Template - Virtusa Corporate)
Contents:
Structure of a program
Variables & Data types
Constants
Operators
Basic Input/output
Control Structures
Functions
Arrays
Character Sequences
Pointers and Dynamic Memory
Unions
Other Data Types
Input/output with files
Searching
Sorting
Introduction to data structures
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofsAlex Pruden
This paper presents Reef, a system for generating publicly verifiable succinct non-interactive zero-knowledge proofs that a committed document matches or does not match a regular expression. We describe applications such as proving the strength of passwords, the provenance of email despite redactions, the validity of oblivious DNS queries, and the existence of mutations in DNA. Reef supports the Perl Compatible Regular Expression syntax, including wildcards, alternation, ranges, capture groups, Kleene star, negations, and lookarounds. Reef introduces a new type of automata, Skipping Alternating Finite Automata (SAFA), that skips irrelevant parts of a document when producing proofs without undermining soundness, and instantiates SAFA with a lookup argument. Our experimental evaluation confirms that Reef can generate proofs for documents with 32M characters; the proofs are small and cheap to verify (under a second).
Paper: https://eprint.iacr.org/2023/1886
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
In the rapidly evolving landscape of technologies, XML continues to play a vital role in structuring, storing, and transporting data across diverse systems. The recent advancements in artificial intelligence (AI) present new methodologies for enhancing XML development workflows, introducing efficiency, automation, and intelligent capabilities. This presentation will outline the scope and perspective of utilizing AI in XML development. The potential benefits and the possible pitfalls will be highlighted, providing a balanced view of the subject.
We will explore the capabilities of AI in understanding XML markup languages and autonomously creating structured XML content. Additionally, we will examine the capacity of AI to enrich plain text with appropriate XML markup. Practical examples and methodological guidelines will be provided to elucidate how AI can be effectively prompted to interpret and generate accurate XML markup.
Further emphasis will be placed on the role of AI in developing XSLT, or schemas such as XSD and Schematron. We will address the techniques and strategies adopted to create prompts for generating code, explaining code, or refactoring the code, and the results achieved.
The discussion will extend to how AI can be used to transform XML content. In particular, the focus will be on the use of AI XPath extension functions in XSLT, Schematron, Schematron Quick Fixes, or for XML content refactoring.
The presentation aims to deliver a comprehensive overview of AI usage in XML development, providing attendees with the necessary knowledge to make informed decisions. Whether you’re at the early stages of adopting AI or considering integrating it in advanced XML development, this presentation will cover all levels of expertise.
By highlighting the potential advantages and challenges of integrating AI with XML development tools and languages, the presentation seeks to inspire thoughtful conversation around the future of XML development. We’ll not only delve into the technical aspects of AI-powered XML development but also discuss practical implications and possible future directions.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
Climate Impact of Software Testing at Nordic Testing DaysKari Kakkonen
My slides at Nordic Testing Days 6.6.2024
Climate impact / sustainability of software testing discussed on the talk. ICT and testing must carry their part of global responsibility to help with the climat warming. We can minimize the carbon footprint but we can also have a carbon handprint, a positive impact on the climate. Quality characteristics can be added with sustainability, and then measured continuously. Test environments can be used less, and in smaller scale and on demand. Test techniques can be used in optimizing or minimizing number of tests. Test automation can be used to speed up testing.
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
3. Introduction
C# Fundamentals
C# Pre defined Types
C# Expressions
Debugging Application
Conditional & Iteration Statement
Class, Method & Constructor
XML Comments
Static Class Member
Designing Object
Inheritance
Polymorphism
Arrays & Collections
Interface
Exception Handling
4. C# is intended to be a simple, modern, general-
purpose, object-oriented programming
language
It is very sophisticated programming language
It is developed by Microsoft with its .NET
initiatives
The language is intended for use in developing
Software Components
5. Introduction
C# Fundamentals
C# Pre defined Types
C# Expressions
Debugging Application
Conditional & Iteration Statement
Class, Method & Constructor
XML Comments
Static Class Member
Designing Object
Inheritance
Polymorphism
Arrays & Collections
Interface
Exception Handling
6. Program execution begins at Main()
The using keyword refers to resources in the
.NET framework class library
Statements are commands that perform actions
A program is made up of many separate statement
Statement are separated by a semicolon
Braces are used to group statement
7. Use indentation to indicate enclosing
statements
C# is case sensitive
White space is ignored
Indicate single line comment by using //
Indicate multiple line comment by using
/*and*/
8. Introduction
C# Fundamentals
C# Pre defined Types
C# Expressions
Debugging Application
Conditional & Iteration Statement
Class, Method & Constructor
XML Comments
Static Class Member
Designing Object
Inheritance
Polymorphism
Arrays & Collections
Interface
Exception Handling
9. Types are used to declare variables
Variables store different kinds of data
Predefined types are those provided by C# and
.NET framework
You can also defined your own
Variable must be declared before you can use
them
10. Predefined type Definition Bytes
Byte Integer between 0 and 255 1
Sbyte Integer between -128 and 127 1
Short Integer between -32768 and 32767
2
Ushort Integer between 0 and 65535 2
Int Integer between -2147483648 and 2147483647
4
Uint Integer between 0 and 4294967295
4
Long
Integer between -9223372036854775808 and
9223372036854775807 8
Ulong Integer between 0 and 18446744073709551615
8
Bool Boolean value: true or false
1
Float
Single-precision floating point value (non-whole
number)
4
Double Double-precision floating point value
8
Decimal Precise decimal value to 28 significant digits
12
Object Base type of all other types
N/A
Char Single Unicode character between 0 and 65535
2
String An unlimited sequence of Unicode characters
N/A
11. A variable is a storage location for a particular type
Declaring
Assign a type
Assign a name
End with a semicolon
Ex. int noOfUser; string firstName;
Initializing
Use assignment operator
Assign a value
End with a semicolon
Ex. string firstName = “Mahedee”;
Assigning literal variable
Add a type suffix
Ex. decimal deposit = 50000M;
12. string str = “Hello world”; //Hello world
Literal string
string str = “”Hello””; //”Hello”
Escape character
string str = “HellonWorld”; a new line is added
between Hello and World
Using verbatim string
string str = @”Hellon”; Hellon
13. Declare using const keyword and type
You must assign a value at the time of
declaration
Examples
const double pi = 3.14;
const int earthRadius = 6378;
14. User defined data type
Purpose of enumeration type is to use constant
values
Process to create enumeration type
Create an enumeration type
Declare variable of that type
Assign values to those variables
16. Implicit
Performed by the compiler on operations that are
guaranteed not to truncate information
int x = 123456; // int is a 4-byte integer
long y = x; // implicit conversion to a long
Explicit
Where you to explicitly ask the compiler to perform
a conversion that otherwise could lose information
int x = 500;
short z = (short) x;
// explicit conversion to a short, z contains the value 500
17. Introduction
C# Fundamentals
C# Pre defined Types
C# Expressions
Debugging Application
Conditional & Iteration Statement
Class, Method & Constructor
XML Comments
Static Class Member
Designing Object
Inheritance
Polymorphism
Arrays & Collections
Interface
Exception Handling
18. An expression is a sequence of operators and
operands
The purpose of writing an expression is to
perform an action and return a value
19. Expressions are evaluated according to operator
precedence
Example: 10 + 20 / 5 (result is 14)
Parenthesis can be used to control the order of
evaluation.
Ex. (10 + 20) / 5 (result is 6)
Operator precedence is also determined by
associativity
Binary operators are left associative i.e evaluated from
left to right.
Assignment and conditional operators are right
associative i.e evaluated from right to left
20. Introduction
C# Fundamentals
C# Pre defined Types
C# Expressions
Debugging Application
Conditional & Iteration Statement
Class, Method & Constructor
XML Comments
Static Class Member
Designing Object
Inheritance
Polymorphism
Arrays & Collections
Interface
Exception Handling
22. Step In = F11 = Step into a Method
Step Out = Shift + F11 = Steps up and out of a
method back to the caller
Step Over = F10 = Steps past a method to the
next statement
Stop Debugging = Shift + F5 = Stops a
debugging session
23.
24. Introduction
C# Fundamentals
C# Pre defined Types
C# Expressions
Debugging Application
Conditional & Iteration Statement
Class, Method & Constructor
XML Comments
Static Class Member
Designing Object
Inheritance
Polymorphism
Arrays & Collections
Interface
Exception Handling
25. A conditional statement allows you to control
the flow of your application by selecting the
statement that is executed, based on the value
of a Boolean expression.
26. if statement
if ( sales > 10000 ) {
bonus += .05 * sales;
}
if else statement
if ( sales > 10000 ) {
bonus += .05 * sales;
}
else {
bonus = 0;
}
if else if satement
if ( sales > 10000 ) {
bonus += .05 * sales;
}
else if ( sales > 5000 ) {
bonus = .01 * sales;
}
else {
bonus = 0;
if ( priorBonus == 0 ) {
// Schedule a Meeting;
}
}
27. Switch statements are useful for selecting one branch
of execution from a list of mutually-exclusive choices.
switch( favoriteAnimal ) {
case Animal.Antelope:
// herbivore-specific statements
break;
case Animal.Elephant:
// herbivore-specific statements
break;
case Animal.Lion:
// carnivore-specific statements
break;
case Animal.Osprey:
// carnivore-specific statements
break;
default:
//default statemennt
}
28. C# provides several looping mechanisms,
which enable you to execute a block of code
repeatedly until a certain condition is met
Looping mechanism
for loop.
while loop.
do loop.
29. Use when you know how many times you
want to repeat the execution of the code
Syntax:
for (initializer; condition; iterator) {
statement-block
}
Example:
for ( int i = 0; i < 10; i++ ) {
Console.WriteLine( "i = {0}",i );
}
30. A Boolean test runs at the start of the loop and
if tests as False, the loop is never executed.
The loop executed until the condition becomes
false.
Syntax:
while (true-condition) {
statement-block
}
Example
while ( i <= 10 ) {
Console.WriteLine(i++);
}
31. The continue keyword to start the next loop iteration
without executing any remaining statements
The break keyword is encountered, the loop is
terminated
Example:
int i = 0;
while ( true ) {
i++;
if(i>5)
continue;
if(i>= 10)
break;
Console.WriteLine(i);
}
32. Executes the code in the loop and then
performs a Boolean test. If the expression as
true then the loop repeats until the expression
test as false
Syntax:
do {
statements
} while (boolean-expression);
Example:
int i = 1;
do {
Console.WriteLine("{0}", i++);
} while ( i <= 10 );
33. Introduction
C# Fundamentals
C# Pre defined Types
C# Expressions
Debugging Application
Conditional & Iteration Statement
Class, Method & Constructor
XML Comments
Static Class Member
Designing Object
Inheritance
Polymorphism
Arrays & Collections
Interface
Exception Handling
34. Classes
Like blueprint of objects
Contain methods and data
Objects
Are instances of class
Create using the new keyword
Have actions
35. Value Types
Directly contain data
Stored on the stack
Must be initialized
Cannot be null
An int is a value type
Example: int a; a = 15;
a
15
36. Contain a reference to the data
Stored on the heap
Declared using new key word
.NET garbage collection handles destruction
A class is a reference type
Example: EmployeeInfo c;
c
* 15
37. Boxing
Treat value types like reference types
Example: object boxedValue = (object) x;
Unboxing
Treat reference types like value types
Example: int y = (int) boxedValue;
38. How to define class
public class Investor
{
public string firstName;
public string lastName;
public double purchasePower;
}
How to create an object
Example: Investor objInvestor = new Investor();
How to access class variable
Example: objInvestor.firstName = “Mahedee”;
39. Declaring namespace
namespace Bluchip
{
public class Investor
{
public string firstName;
public string lastName;
public double purchasePower;
}
}
Nested namespaces
namespace Bluchip
{
namespace InvestorSetup
{
public class Investor
{
//to do
}
}
}
The using namespace
using Bluechip
using Bluechip.InvestorSetup
40. Access modifiers are used to define the
accessibility level of class members
public: Access not limited
private: Access limited to the containing class
internal: Access limited to this program
protected: Access limited to the containing class and
to types derived from the containing class
protected internal: Access limited to the containing
class, derived classes or to members of this program.
41. A method is a class member that is used to define the actions
Declare Mathod:
class Lion {
private int weight;
public bool IsNormalWeight() {
if ( ( weight < 100 ) || ( weight > 250 ) ) {
return false;
}
return true;
}
public void Eat() { }
public int GetWeight() {
return weight;
}
}
Invoke method:
Lion bigLion = new Lion();
if ( bigLion.IsNormalWeight() == false ) {
Console.WriteLine("Lion weight is abnormal");
}
42. Passing by value
class Lion {
private int weight;
public void SetWeight( int newWeight ) {
weight = newWeight;
}
}
Lion bigLion = new Lion();
int bigLionWeight = 200;
bigLion.SetWeight( bigLionWeight );
43. Passing by reference
Using the ref keyword
Definite assignment
Using out parameter keyword
Allow you to initialize variable in method
Use if you want a method to modify or return
multiple values
Achieve this by passing the method a reference
44. class Zoo {
private int streetNumber = 123;
private string streetName = "High Street";
private string cityName = "Sammamish";
public void GetAddress(ref int number, ref string street, ref string
city)
{
number = streetNumber;
street = streetName;
city = cityName;
}
}
45. class ClassMain {
static void Main(string[] args) {
Zoo localZoo = new Zoo();
// note these variables are not initialized
int zooStreetNumber;
string zooStreetName;
string zooCity;
localZoo.GetAddress(out zooStreetNumber, out
zooStreetName, out zooCity);
Console.WriteLine(zooCity);
// Writes "Sammamish" to a console
}
}
46. When you pass a reference type to a method, the
method can alter the actual object.
using System;
namespace LearningCSharp {
class MainClass {
static void Main(string[] args) {
Zoo myZoo = new Zoo();
Lion babyLion = new Lion();
myZoo.AddLion( babyLion );
}
}
class Lion {
public string location;
}
class Zoo {
public void AddLion( Lion newLion ) {
newLion.location = "Exhibit 3";}
}
}
47. Method overloading is a language feature that
enables you to create multiple methods in one
class that have the same name but that take
different signatures
By overloading a method, you provide the
users of your class with a consistent name for
an action while also providing them with
several ways to apply that action.
Overloaded methods are a good way for you to
add new functionality to existing code.
48. class Zoo {
public void AddLion( Lion newLion ) {
// Place lion in an appropriate exhibit
}
public void AddLion( Lion newLion, int exhibitNumber ) {
// Place the lion in exhibitNumber exhibit
}
}
Zoo myZoo = new Zoo();
Lion babyLion = new Lion();
myZoo.AddLion( babyLion );
myZoo.AddLion( babyLion, 2 );
49. Constructors are special methods that
implement the actions that are required to
initialize an object.
Instance constructors are special type methods
that implements the actions required to
initialize an object.
Have the same name as the name of the class
Default constructor takes no parameter
50. public class Lion {
private string name;
public Lion() {
Console.WriteLine("Constructing Lion");
}
public Lion( string newLionName ) {
this.name = newLionName;
}
}
Lion babyLion = new Lion();
Console.WriteLine("Made a new Lion object");
Output:
Constructing Lion
Made a new Lion object
51. When you use the readonly modifier on a member
variable, you can only assign it a value when the class
or object initializes, either by directly assigning the
member variable a value, or by assigning it in the
constructor.
Use the readonly modifier when a const keyword is not
appropriate because you are not using a literal
value—meaning that the actual value of the variable is
not known at the time of compilation.
52. class Zoo {
private int numberAnimals;
public readonly decimal admissionPrice;
public Zoo() {
// Get the numberAnimals from some source...
if ( numberAnimals > 50 ) {
admissionPrice = 25;
}
else {
admissionPrice = 20;
}
}
}
53. Create multiple constructor that have same
name but different signatures
It is often useful to overload a constructor to
allow instances to be created in more than one
way.
54. public class Lion {
private string name;
private int age;
public Lion() : this ( "unknown", 0 ) {
Console.WriteLine("Default {0}", name);
}
public Lion( string theName, int theAge ) {
name = theName;
age = theAge;
Console.WriteLine("Specified: {0}", name);
}
}
Lion adoptedLion = new Lion();
55. Introduction
C# Fundamentals
C# Pre defined Types
C# Expressions
Debugging Application
Conditional & Iteration Statement
Class, Method & Constructor
XML comments
Static Class Member
Designing Object
Inheritance
Polymorphism
Arrays & Collections
Interface
Exception Handling
56.
57.
58. Introduction
C# Fundamentals
C# Pre defined Types
C# Expressions
Debugging Application
Conditional & Iteration Statement
Class, Method & Constructor
XML Comments
Static Class Member
Designing Object
Inheritance
Polymorphism
Arrays & Collections
Interface
Exception Handling
59. Static members belong to the class, rather than an
instance.
Static constructors are used to initialize a class.
Initialize before an instance of the class is created.
Shared by all instance of the class
Classes can have static members, such as
properties, methods and variables.
Because static members belong to the class, rather than
an instance, they are accessed through the class, not
through an instance of the class.
60. using System;
namespace StaticExample {
class ZooDemo {
static void Main(string[] args) {
Console.WriteLine( "Family: {0}", Lion.family );
Console.ReadLine();
}
}
class Lion {
public static string family = "felidae";
}
}
Output: fedilae
61. Instance constructors are used to initialize an
object
Static constructors are used to initialize a class
Will only ever be executed once
Run before the first object of that type is
created.
Have no parameter
Do not take an access modifier
May co-exist with a class constructor
62. using System;
namespace StaticConstructor {
class RandomNumberGenerator {
private static Random randomNumber;
static RandomNumberGenerator() {
randomNumber = new Random();
}
public int Next() {
return randomNumber.Next();
}
}
class Class1 {
static void Main(string[] args) {
RandomNumberGenerator r = new RandomNumberGenerator();
for ( int i = 0; i < 10; i++ ) {
Console.WriteLine( r.Next() );
}
}
}
}
63. Introduction
C# Fundamentals
C# Pre defined Types
C# Expressions
Debugging Application
Conditional & Iteration Statement
Class, Method & Constructor
XML Comments
Static Class Member
Designing Object
Inheritance
Polymorphism
Arrays & Collections
Interface
Exception Handling
64. Structure Design Object Oriented Design
Process centered Object centered
Reveals data Hide data
Single unit Modular unit
One time use Reusable
Ordered algorithm No ordered algorithm
65. Programs are easier to design because objects
reflect real-world items.
Applications are easier for users because data -
they do not need is hidden.
Objects are self-contained units.
Productivity increases because you can reuse
code.
Systems are easier to maintain and adapt to
changing business needs.
66. Grouping related piece of information and
processes into self-contained unit.
Makes it easy to change the way things work under
the cover without changing the way users interact.
Hiding internal details.
Makes your object easy to use.
67. Protect access to the state of object.
It like fields, but they operate much like
methods.
The get and set statements are called accessors.
private double balance;
public double Balance {
get {
return balance;
}
set {
balance = value;
}
}
68. Introduction
C# Fundamentals
C# Pre defined Types
C# Expressions
Debugging Application
Conditional & Iteration Statement
Class, Method & Constructor
XML Comments
Static Class Member
Designing Object
Inheritance
Polymorphism
Arrays & Collections
Interface
Exception Handling
69. Inheritance specifies an is-a kind of
relationship
Derived classes inherits properties and
methods from base class, allowing code reuse
Derived classes become more specialized.
70. public class Animal {
public bool IsSleeping;
public void Sleep() {
Console.WriteLine("Sleeping");
}
public void Eat() { }
}
public class Antelope : Animal {
}
public class Lion : Animal {
public void StalkPrey() { }
}
public class Elephant : Animal {
public int CarryCapacity;
}
Uses:
Elephant e = new Elephant();
e.Sleep();
71. public enum GenderType {
Male,
Female
}
public class Animal {
public Animal() {
Console.WriteLine("Constructing Animal");
}
public Animal( GenderType gender ) {
if ( gender == GenderType.Female ) {
Console.WriteLine("Female ");
}
else {
Console.WriteLine("Male ");
}
}
}
public class Elephant : Animal {
public Elephant( GenderType gender ) : base( gender ) {
Console.WriteLine("Elephant");
}
}
Elephant e = new Elephant(GenderType.Female); //Output: Female New line Elephant
72. You cannot derive from a sealed class
Prevents the class from being overridden or
extended by third parties
public sealed class Elephant {
...
}
73. Introduction
C# Fundamentals
C# Pre defined Types
C# Expressions
Debugging Application
Conditional & Iteration Statement
Class, Method & Constructor
XML Comments
Static Class Member
Designing Object
Inheritance
Polymorphism
Arrays & Collections
Interface
Exception Handling
74. Polymorphism is an object-oriented concept
that enables you to treat your derived classes
in a similar manner, even though they are
different.
When you create derived classes, you provide
more specialized functionality;
polymorphism enables you to treat these new
objects in a general way.
75.
76. A virtual method is one whose implementation
can be replaced by a method in a derived class.
Use the keyword virtual, in the base class
method
Use the override keyword, in the derived
class method.
When you override a virtual method, the
overriding method must have the same
signature as the virtual method.
77. public class Animal {
public virtual void Eat() {
Console.WriteLine("Eat something");
}
}
public class Cat : Animal {
public override void Eat() {
Console.WriteLine("Eat small animals");
}
}
public void FeedingTime( Animal someCreature ) {
if ( someCreature.IsHungry ) {
someCreature.Eat();
}
}
Cat myCat = new Cat();
FeedingTime(myCat);
78. The base keyword is used in derived classes to access
members of the base class.
public class Animal {
public virtual void Eat() {
Console.WriteLine("Eat something");
}
}
public class Cat : Animal {
public void StalkPrey() { }
public override void Eat() {
base.Eat();
Console.WriteLine("Eat small animals");
}
}
79. An abstract class is a generic base class
Contains an abstract method that must be
implemented by a derived class.
An abstract method has no implementation in
the base class
Can contain non abstract members
Any class that contains abstract members must
be abstract
80. public abstract class Animal {
public abstract void Eat();
}
public class Mouse : Animal {
public override void Eat() {
Console.WriteLine("Eat cheese");
}
}
81. Introduction
C# Fundamentals
C# Pre defined Types
C# Expressions
Debugging Application
Conditional & Iteration Statement
Class, Method & Constructor
XML Comments
Static Class Member
Designing Object
Inheritance
Polymorphism
Arrays & Collections
Interface
Exception Handling
82. A data structure that contains a number of
variables called element of the array.
All the array elements must be of the same
type.
Arrays are zero indexed.
Arrays can be:
Single- dimentional, an array with the rank one.
Multidimentional, an array with the rank more than
one
Jagged, an array whose elements are arrays
83. Method Description
Sort Sorts the elements in an array
Clear Sets a range of elements to zero or null
Clone Creates a copy of the array
GetLength Returns the length of a given dimension
IndexOf Returns the index of the first occurrence of a value
Length Gets the number of elements in the specified
dimension of the array
84. Declare the array by adding a set of square
brackets to the end of the variable type of the
individual elements
int[] MyIntegerArray;
Instantiate to create
int[] numbers = new int[5];
To create an array of type object
object[] animals = new object[100];
86. Using foreeach statement repeats the
embedded statement(s) for each elements in
the arrays.
int[] numbers = {4, 5, 6, 1, 2, 3, -2, -1, 0};
foreach (int i in numbers) {
Console.WriteLine(i);
}
87. using System;
namespace ParameterExample {
public class ParamExample {
public int Sum(int[] list) {
int total = 0;
foreach ( int i in list ) {
total += i;
}
return total;
}
}
class Tester {
static void Main(string[] args) {
ParamExample pe = new ParamExample();
int[] tester = {1, 2, 3, 4, 5, 6, 7 };
int total = pe.Sum( tester );
Console.WriteLine( total ); // 28
}
}
}
88. params keyword used to pass a variable
number of arguments to method
class ParamExample {
public string Combine(string s1, string s2,
params object[] others) {
string combination = s1 + " " + s2;
foreach ( object o in others ) {
combination += " " + o.ToString();
}
return combination;
}
}
You can use this method as follows:
string combo = pe.Combine("One", "two", "three", "four" );
// combo has the value "One two three four"
combo = pe.Combine("alpha", "beta");
// combo has the value "alpha beta"
89. When a class contains an array, or a collection,
it is useful to access the information as though
the class itself were an array.
An indexer is a property that allows you to
index an object in the same way as an array.
90. public class Zoo {
private Animal[] theAnimals;
public Animal this[int i] {
get {return theAnimals[i];}
set { theAnimals[i] = value;}
}
public Zoo() {
theAnimals = new Animal[100];
}
}
public abstract class Animal {
abstract public void Eat();
}
public class Lion : Animal {
public override void Eat() { }
}
public class Elephant : Animal {
public override void Eat() { }
}
public class Antelope : Animal {
public override void Eat() { }
}
91. class ZooKeeper {
static void Main(string[] args) {
Zoo myZoo = new Zoo();
myZoo[0] = new Elephant();
myZoo[1] = new Lion();
myZoo[2] = new Lion();
myZoo[3] = new Antelope();
Animal oneAnimal = myZoo[3];
}
}
92. Lists, Queues, Statcks and Hash Tables are
common way to manage data in an application
List: A collection that allows you access by index.
Example: An array is a list, an ArrayList is a list
Queue: First in first out collection of objects.
Example: Waiting in line at a ticket office.
Stack: Last in first out collection of objects.
Example: a pile of plates
Hash Tables: Represents a collection of associated
keys and values organized around the hash code
of the key. Example: Dictionary
93. ArrayList does not have fixed size; it grows as
needed
Use Add(object) to add an object to the end of
the ArrayList
Use [] to access elements of the ArrayList.
Use TrimToSize() to reduce the size to fit the
number of elements in the ArrayList
Use clear to remove all the elements
Can set the capacity explicitly
94. public class Zoo {
private ArrayList theAnimals;
public ArrayList ZooAnimals {
get {return theAnimals;}
}
public Animal this[int i] {
get {return (Animal) theAnimals[i];}
set {theAnimals[i] = value;}
}
public Zoo() {
theAnimals = new ArrayList();
}
}
95. public abstract class Animal {
abstract public void Eat();
}
public class Lion : Animal {
public override void Eat() { }
}
public class Elephant : Animal {
public override void Eat() { }
}
public class Antelope : Animal {
public override void Eat() { }
}
96. public class ZooKeeper {
static void Main(string[] args) {
Zoo myZoo = new Zoo();
myZoo.ZooAnimals.Add( new Lion() );
myZoo.ZooAnimals.Add( new Elephant() );
myZoo.ZooAnimals.Insert( 1, new Lion() );
Animal a = myZoo[0];
myZoo[1] = new Antelope();
}
}
97. Queues: first in, first out
Enqueue places object in the Queue
Dequeue removes objects from the Queue.
Stacks: last in, first out
Push places object in the stack
Pop removes object from the stack
Counts get the number of objects contained in a
stack or queue
98. using System;
using System.Collections;
class Message {
private string messageText;
public Message (string s) {
messageText = s;
}
public override string ToString() {
return messageText;
}
}
class Buffer {
private Queue messageBuffer;
public void SendMessage( Message m ) {
messageBuffer.Enqueue( m );
}
public void ReceiveMessage( ) {
Message m = (Message) messageBuffer.Dequeue();
Console.WriteLine( m.ToString() );
}
public Buffer() {
messageBuffer = new Queue();
}
}
99. class Messenger {
static void Main(string[] args) {
Buffer buf = new Buffer();
buf.SendMessage( new Message("One") );
buf.SendMessage( new Message("Two") );
buf.ReceiveMessage ();
buf.SendMessage( new Message("Three") );
buf.ReceiveMessage ();
buf.SendMessage( new Message("Four") );
buf.ReceiveMessage ();
buf.ReceiveMessage ();
}
}
The preceding code produces the following output:
One
Two
Three
Four
100. using System;
using System.Collections;
class Message {
private string messageText;
public Message (string s) {
messageText = s;
}
public override string ToString() {
return messageText;
}
}
class Buffer {
private Stack messageBuffer;
public void SendMessage( Message m ) {
messageBuffer.Push( m );
}
public void ReceiveMessage( ) {
Message m = (Message) messageBuffer.Pop();
Console.WriteLine( m.ToString() );
}
public Buffer() {
messageBuffer = new Stack();
}
}
101. class Messenger {
static void Main(string[] args) {
Buffer buf = new Buffer();
buf.SendMessage( new Message("One") );
buf.SendMessage( new Message("Two") );
buf.ReceiveMessage ();
buf.SendMessage( new Message("Three") );
buf.ReceiveMessage ();
buf.SendMessage( new Message("Four") );
buf.ReceiveMessage ();
buf.ReceiveMessage ();
}
}
The preceding code produces the following output:
Two
Three
Four
One
102. A hash table is a data structure that is designed
for fast retrieval
Book b2 = new Book("Inside C#", 0735612889 );
myReferences.bookList.Add(b2.ISBN, b2);
Book b = (Book) myReferences.bookList[0735612889];
Console.WriteLine( b.Title );
103. Introduction
C# Fundamentals
C# Pre defined Types
C# Expressions
Debugging Application
Conditional & Iteration Statement
Class, Method & Constructor
XML Comments
Static Class Member
Designing Object
Inheritance
Polymorphism
Arrays & Collections
Interface
Exception Handling
104. Interface is a reference type that defines contact
Specifies the members that must be supplied
by classes or interfaces that implement the
interface
Can contain method, properties, indexers,
event.
Does not provides implementation for the
member
Can inherits zero or more members
105. interface ICarnivore {
bool IsHungry { get; }
Animal Hunt();
void Eat(Animal victim);
}
public class Lion: ICarnivore {
private bool hungry;
public bool IsHungry {
get {
return hungry;
}
}
107. Abstract Class
Is a special kind of class that cannot be instantiated
An abstract class is only to be sub-classed(inherited from)
The advantage is that it enforces certain hierarchies for all the
subclasses
It is a kind of contract that forces all the subclasses to carry on the
same hierarchies or standards
Interface
An interface is not a class
It is an entity that is defined by the word Interface
Interface has no implementation; it only has the signature
The main difference between them is that a class can implement
more than one interface but can only inherit from one abstract class
Since C# doesn’t support multiple inheritance, interfaces are used
to implement multiple inheritance.
108. Introduction
C# Fundamentals
C# Pre defined Types
C# Expressions
Debugging Application
Conditional & Iteration Statement
Class, Method & Constructor
XML Comments
Static Class Member
Designing Object
Inheritance
Polymorphism
Arrays & Collections
Interface
Exception Handling
109. An exception is any error condition or unexpected
behavior that is encountered by an executing program
try {
byte tickets = Convert.ToByte(numberOfTickets.Text);
}
catch (FormatException) {
MessageBox.Show("Format Exception: please enter a number");
}
110. try {
byte tickets = Convert.ToByte(numberOfTickets.Text);
}
catch (FormatException e) {
MessageBox.Show("Format Exception: please enter a number");
}
catch (OverflowException e) {
MessageBox.Show("Overflow: too many tickets");
}
111. A finally block is always executed, regardless of whether an
exception is thrown.
FileStream xmlFile = null;
try {
xmlFile = new FileStream("XmlFile.xml", FileMode.Open);
}
catch( System.IO.IOException e ) {
return;
}
finally {
if ( xmlFile != null ) {
xmlFile.Close();
}
}
112. You can create your own exception classes by deriving from the
Application.Exception class
class TicketException: ApplicationException {
private bool purchasedCompleted = false;
public bool PurchaseWasCompleted {
get {return purchasedCompleted;}
}
public TicketException( bool completed, Exception e ) : base ("Ticket Purchase Error", e ){
purchasedCompleted = completed;
}
}
The ReadData and run_Click methods can use TicketException:
private int ReadData() {
byte tickets = 0;
try {
tickets = Convert.ToByte(textBox1.Text);
}
catch ( Exception e ) {
// check if purchase was complete
throw ( new TicketException( true, e ) );
}
return tickets;
}
decimal bankBalance = 3433.20; // ERROR! This code causes an error because the C# compiler assumes than any literal number with a decimal point is a double, unless otherwise specified. You specify the type of the literal by appending a suffix, as shown in the following example:decimal bankBalance = 3433.20M;A literal is a value that has been hard-coded directly into your source.For example:string x = "This is a literal"; int y = 2; // so is 2, but not y int z = y + 4; // y and z are not literals, but 4 is Some literals can have a special syntax, so you know what type the literal is://The 'M' in 10000000M means this is a decimal value, rather than int or double. varaccountBalance = 10000000M;
C# has four types of operators: unary, binary, ternary, and afew others that don’t fit into a category.
C provides two sytles of flow control:BranchingLoopingBranching is deciding what actions to take and looping is deciding how many times to take a certain action.Branching:Branching is so called because the program chooses to follow one branch or another.
Difference between readonly and constant.
Array is the collection of values of the same data typethe variables in an array is called array elementsArray is a reference type data typeThe array structure in System's MemoryArray list is a class .when you want to access the elements of an array through its index value location in an array,use an ArrayList.The use of the arraylist is an alternative to the use of the array.The Methods Of ArrayList class are1)Add2)Remove3)Clear4)Insert5)TrimToSize6)Sort7)Reverse->another difference between array list and array is arraylist can dynamically increase or decrease its size were as array size is constant