SlideShare a Scribd company logo
1 of 40
LECTURE 2
BY: RUBYNA VOHRA
SHARE OUT
1. 3 job postings for the companies you want to work for
2. Research what qualifications you need to get that job
3. The company culture of the 3 companies you chose
4. Project ideas to add onto your resume
AGENDA
• Creating Projects Within Visual Studio 2010
• Explain the structure of a C# application.
• Writing a C# Application
• Print statements + Variables + Error Handling
• Documenting an Application
• Running and Debugging Applications by Using Visual Studio 2010
CREATING PROJECTS WITHIN VISUAL
STUDIO 2010
PARTS OF A C#
PROJECT
• Solution: a container used by Visual
Studio to organize one or more related
projects.
• When you open a solution in
Visual Studio, it automatically
loads all the projects that the
solution contains.
• Workspace: This is the space where
you actually work on a part of your
program.
1. CREATE A SOLUTION
2. ADD A PROJECT
3: YOU’RE READY TO CODE!
COMPILING VS RUNNING
• Compile-time is the time at which the source code is converted into an
executable code (converting from C# language to byte language – the computer
understands byte language)
• Run time is the time at which the executable code has started running i.e. your
output begins producing.
STRUCTURE OF A C# APPLICATION
• The first line of the program using System; - the using keyword is used to include the System namespace in the
program. A program generally has multiple using statements.
• The next line has the namespace declaration. A namespace is a collection of classes.
The HelloWorldApplication namespace contains the class HelloWorld.
• The next line has a class declaration, the class HelloWorld contains the data and method definitions that your
program uses. Classes generally contain multiple methods. Methods define the behavior of the class. However,
the HelloWorld class has only one method Main.
• The next line defines the Main method, which is the entry point for all C# programs. The Main method states what
the class does when executed.
• The next line /*...*/ is ignored by the compiler and it is put to add comments in the program.
• The Main method specifies its behavior with the statement Console.WriteLine("Hello World");
• WriteLine is a method of the Console class defined in the System namespace. This statement causes the message
"Hello, World!" to be displayed on the screen.
• The last line Console.ReadKey(); is for the VS.NET Users. This makes the program wait for a key press and it
prevents the screen from running and closing quickly when the program is launched from Visual Studio .NET.
RUNNING YOUR CODE!
PRINT STATEMENTS
• Console.WriteLine(“your text”);
• After the console prints your text, the cursor will start on a new line
• Console.Write(“your text”);
• After the console prints your text, the cursor will stay on the same line
VARIABLES – 5 DIFFERENT DATA TYPES
• int - integers (whole numbers) such as 0, -65
• double - decimals such as 19.99 or -19.99
• char - characters such as 'a' or 'B'. Char values are surrounded by single quotes
• string - text, such as "Hello World". String values are surrounded by double
quotes
• bool - Boolean such as true or false
VARIABLE SYNTAX
• type variableName = value; int myNum = 15;
myNum = 20; // myNum is now 20
Console.WriteLine(myNum);
int myNum = 15;
myNum = 20; // myNum is now 20
Console.WriteLine(myNum);
int myNum;
myNum = 15;
Console.WriteLine(myNum);
string name = ”Ruby";
Console.WriteLine(name);
CONCATENATION
• Concatenation: Combining a string with a variable
string name = "John";
Console.WriteLine("Hello " + name);
string firstName = "John ";
string lastName = "Doe";
string fullName = firstName + lastName;
Console.WriteLine(fullName);
MORE EXAMPLES …
int x = 5;
int y = 6;
Console.WriteLine(x + y); // Print the value of x + y
int x = 5, y = 6, z = 50;
Console.WriteLine(x + y + z);
MEANINGFUL NAMES
// Good
int minutesPerHour = 60;
// OK, but not so easy to understand what m actually is
int m = 60;
ERROR HANDLING
• An exception is a problem that happens during the execution of a program.
• try − A try block identifies a block of code for which particular exceptions is activated. It is
followed by one or more catch blocks.
• catch − A program catches an exception with an exception handler at the place in a program
where you want to handle the problem. The catch keyword indicates the catching of an
exception.
• finally − The finally block is used to execute a given set of statements, whether an exception is
thrown or not thrown. For example, if you open a file, it must be closed whether an exception is
raised or not.
• throw − A program throws an exception when a problem shows up. This is done using a throw
keyword.
WHY IS COMMENTING IMPORTANT?
• For you to understand X amount of time later
• For your colleagues to understand (marketing, development, etc.)
• Can make code maintenance much easier, as well as helping make finding bugs
faster.
• Clients are able to use your code efficiently
• Organization
WHAT IS COMMENTING?
• All programs should be commented in such a manner as to easily describe (in English) the
purpose of the code and any algorithms used to accomplish the purpose.
• A user should be able to utilize a previously written program (or function) without ever having to
look at the code, simply by reading the comments.
• Commenting is the "art" of describing what your program is going to do in "high level" English
statements. Commenting is best done before actually writing the code for your program.
• Comments are specially marked lines of text in the program that are IGNORED.
• There are usually two syntactic ways to comment.
• The first is called a single line comment and, as implied, only applies to a single line in the "source
code" (the program).
• The second is called a Block comment and refers usually refers to a paragraph of text. A block comment
has a start symbol and an end symbol and everything between is ignored by the computer
HOW TO COMMENT CODE
INCLUDE
• what the function does.
• what arguments the function
expects.
• any known issues with the code.
• up-to-date information.
Information about code that has
since been changed is of no use
to anyone.
• credit where credit is due.
Make sure to credit anyone who
contributed to the code!
AVOID
• unnecessary information.
Don’t include anything not related to the code and
avoid over explaining.
• assuming the user’s knowledge.
The documentation needs to be helpful to everyone,
from experts to beginners.
• confusing formatting.
Doesn’t matter how much information is in the
documentation if no one can read it.
• ambiguous or hard to understand language.
Documentation has been standardized to be written
in English, so it is going to be used by non-native
speakers of English as well.
NOT HOW but… WHAT
DOCUMENTING YOUR CODE (COMMENTS)
/* The code below will print the words Hello World to
the screen, and it is amazing */
Console.WriteLine("Hello World!");
// This is a comment
Console.WriteLine("Hello World!");
HOW TO COMMENT YOUR FILES
• The first four lines of any program:
• Full Name:
• Date:
• File Name:
• Purpose:
DEBUGGING APPLICATIONS IN VISUAL
STUDIO
SET A BREAKPOINT AND START THE DEBUGGER
• Set a breakpoint and start the debugger
• F5 (Debug > Start Debugging) or the Start Debugging button in the debug toolbar
• The debugger runs to the first breakpoint that it encounters. If the app is not yet
running, F5 starts the debugger and stops at the first breakpoint.
• A breakpoint indicates where Visual Studio should suspend your running code so
you can take a look at the values of variables, or the behavior of memory, or
whether or not a branch of code is getting run.
• You can set a breakpoint by clicking in the margin to the left of a line of code.
NAVIGATE CODE IN THE DEBUGGER USING STEP
COMMANDS
INSPECT VARIABLES WITH THE AUTOS AND LOCALS
WINDOWS
• While debugging, look at the Autos window at the bottom of the code editor.
• In the Autos window, you see variables along with their current value and their
type.
• The Autos window shows all variables used on the current line or the preceding
line
• Next, look at the Locals window. The Locals window shows you the variables that
are currently in scope.
• You can use a Watch window to specify a
variable (or an expression) that you want
to keep an eye on.
• While debugging, right-click an object
and choose Add Watch.
• In this example, you have a watch set on
the f object, and you can see its value
change as you move through the
debugger.
• Unlike the other variable windows,
the Watch windows always show the
variables that you are watching (they're
grayed out when out of scope).
EXAMINE THE CALL STACK
• The Call Stack window shows the order in which methods and functions are
getting called.
• The top line shows the current function (the Update method in this example).
• The second line shows that Update was called from the Path.set property, and so
on.
• The call stack is a good way to examine and understand the execution flow of an
app.
EXAMINE AN EXCEPTION
• When your code throws an exception, the debugger takes you to the line of code
that threw the exception.
• In this example, the Exception Helper shows you a System.Argument exception
and an error message that says that the path is not a legal form.
• So, we know the error occurred on a method or function argument.
DISCUSSION
• Why is this important?
• How can this be useful to me?
• How can I use this in my current
job?
• How can I use this in my future
career?
• What will I get out of this?
• How is this used in the real world
Regroup and discuss after…
COMPLETE THE
WORKSHEET WITH
YOUR GROUP
Regroup and discuss after…

More Related Content

What's hot

Algorithms and flow charts
Algorithms and flow chartsAlgorithms and flow charts
Algorithms and flow chartsChinnu Edwin
 
Fundamental Programming Lect 1
Fundamental Programming Lect 1Fundamental Programming Lect 1
Fundamental Programming Lect 1Namrah Erum
 
Unit 1 program development cycle
Unit 1 program development cycleUnit 1 program development cycle
Unit 1 program development cycleDhana malar
 
Extreme Programming Deployed
Extreme Programming DeployedExtreme Programming Deployed
Extreme Programming DeployedSteve Loughran
 
The four generations of test automation
The four generations of test automationThe four generations of test automation
The four generations of test automationrenard_vardy
 
2018-09 - F# and Fable
2018-09 - F# and Fable2018-09 - F# and Fable
2018-09 - F# and FableEamonn Boyle
 
Improve your TDD skills
Improve your TDD skillsImprove your TDD skills
Improve your TDD skillsXPeppers
 
From objectives to materials
From objectives to materialsFrom objectives to materials
From objectives to materialsOri Pomerantz
 
An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1Blue Elephant Consulting
 
Walmyr Filho - Lessons learned as software engineer working at appear.in
Walmyr Filho - Lessons learned as software engineer working at appear.inWalmyr Filho - Lessons learned as software engineer working at appear.in
Walmyr Filho - Lessons learned as software engineer working at appear.inAgile Lietuva
 
javabasics_ programming development chapter01
javabasics_ programming development chapter01javabasics_ programming development chapter01
javabasics_ programming development chapter01Udeshg90
 

What's hot (20)

Ic lecture8
Ic lecture8 Ic lecture8
Ic lecture8
 
Specification by example
Specification by exampleSpecification by example
Specification by example
 
Algorithms and flow charts
Algorithms and flow chartsAlgorithms and flow charts
Algorithms and flow charts
 
Fundamental Programming Lect 1
Fundamental Programming Lect 1Fundamental Programming Lect 1
Fundamental Programming Lect 1
 
Unit 1 program development cycle
Unit 1 program development cycleUnit 1 program development cycle
Unit 1 program development cycle
 
Extreme Programming Deployed
Extreme Programming DeployedExtreme Programming Deployed
Extreme Programming Deployed
 
The four generations of test automation
The four generations of test automationThe four generations of test automation
The four generations of test automation
 
2018-09 - F# and Fable
2018-09 - F# and Fable2018-09 - F# and Fable
2018-09 - F# and Fable
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Improve your TDD skills
Improve your TDD skillsImprove your TDD skills
Improve your TDD skills
 
From objectives to materials
From objectives to materialsFrom objectives to materials
From objectives to materials
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming Paradigms
 
Interpreted and compiled language
Interpreted and compiled languageInterpreted and compiled language
Interpreted and compiled language
 
An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1
 
Intro1
Intro1Intro1
Intro1
 
Unit 1
Unit 1Unit 1
Unit 1
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Walmyr Filho - Lessons learned as software engineer working at appear.in
Walmyr Filho - Lessons learned as software engineer working at appear.inWalmyr Filho - Lessons learned as software engineer working at appear.in
Walmyr Filho - Lessons learned as software engineer working at appear.in
 
Programming Language
Programming LanguageProgramming Language
Programming Language
 
javabasics_ programming development chapter01
javabasics_ programming development chapter01javabasics_ programming development chapter01
javabasics_ programming development chapter01
 

Similar to Lecture 2

Structure of a C# Program
Structure of a C# ProgramStructure of a C# Program
Structure of a C# ProgramAli Hassan
 
Cis 170 i lab 2 of 7
Cis 170 i lab 2 of 7Cis 170 i lab 2 of 7
Cis 170 i lab 2 of 7helpido9
 
LECTURE 1 - Introduction to Programming.pptx
LECTURE 1 - Introduction to Programming.pptxLECTURE 1 - Introduction to Programming.pptx
LECTURE 1 - Introduction to Programming.pptxAOmaAli
 
intro-to-eclipse.pdf
intro-to-eclipse.pdfintro-to-eclipse.pdf
intro-to-eclipse.pdfSajeev P
 
Cis 170 ilab 2 of 7
Cis 170 ilab 2 of 7Cis 170 ilab 2 of 7
Cis 170 ilab 2 of 7solutionjug4
 
Cis 170 ilab 2 of 7
Cis 170 ilab 2 of 7Cis 170 ilab 2 of 7
Cis 170 ilab 2 of 7comp274
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch casesMeoRamos
 
Membangun Desktop App
Membangun Desktop AppMembangun Desktop App
Membangun Desktop AppFajar Baskoro
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!olracoatalub
 
Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and importiamluqman0403
 
C++ language basic
C++ language basicC++ language basic
C++ language basicWaqar Younis
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting StartedMartin Chapman
 
Csharp Hands On Lab Paul Yao
Csharp Hands On Lab Paul YaoCsharp Hands On Lab Paul Yao
Csharp Hands On Lab Paul YaoMamgmo Magnda
 

Similar to Lecture 2 (20)

Structure of a C# Program
Structure of a C# ProgramStructure of a C# Program
Structure of a C# Program
 
Cis 170 i lab 2 of 7
Cis 170 i lab 2 of 7Cis 170 i lab 2 of 7
Cis 170 i lab 2 of 7
 
LECTURE 1 - Introduction to Programming.pptx
LECTURE 1 - Introduction to Programming.pptxLECTURE 1 - Introduction to Programming.pptx
LECTURE 1 - Introduction to Programming.pptx
 
Cordovilla
CordovillaCordovilla
Cordovilla
 
intro-to-eclipse.pdf
intro-to-eclipse.pdfintro-to-eclipse.pdf
intro-to-eclipse.pdf
 
Cis 170 ilab 2 of 7
Cis 170 ilab 2 of 7Cis 170 ilab 2 of 7
Cis 170 ilab 2 of 7
 
Cis 170 ilab 2 of 7
Cis 170 ilab 2 of 7Cis 170 ilab 2 of 7
Cis 170 ilab 2 of 7
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
 
Membangun Desktop App
Membangun Desktop AppMembangun Desktop App
Membangun Desktop App
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!
 
ID E's features
ID E's featuresID E's features
ID E's features
 
Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and import
 
C++ language basic
C++ language basicC++ language basic
C++ language basic
 
tut0000021-hevery
tut0000021-heverytut0000021-hevery
tut0000021-hevery
 
tut0000021-hevery
tut0000021-heverytut0000021-hevery
tut0000021-hevery
 
Chapter 2- Prog101.ppt
Chapter 2- Prog101.pptChapter 2- Prog101.ppt
Chapter 2- Prog101.ppt
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting Started
 
2621008 - C++ 1
2621008 -  C++ 12621008 -  C++ 1
2621008 - C++ 1
 
Csharp Hands On Lab Paul Yao
Csharp Hands On Lab Paul YaoCsharp Hands On Lab Paul Yao
Csharp Hands On Lab Paul Yao
 
C_Programming_Notes_ICE
C_Programming_Notes_ICEC_Programming_Notes_ICE
C_Programming_Notes_ICE
 

More from Skillspire LLC (20)

Logistics
LogisticsLogistics
Logistics
 
Introduction to analytics
Introduction to analyticsIntroduction to analytics
Introduction to analytics
 
Lecture 31
Lecture 31Lecture 31
Lecture 31
 
Lecture 30
Lecture 30Lecture 30
Lecture 30
 
Lecture 29
Lecture 29Lecture 29
Lecture 29
 
Review
ReviewReview
Review
 
Review version 4
Review version 4Review version 4
Review version 4
 
Review version 3
Review version 3Review version 3
Review version 3
 
Review version 2
Review version 2Review version 2
Review version 2
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
 
Lecture 16
Lecture 16Lecture 16
Lecture 16
 
Lecture 15
Lecture 15Lecture 15
Lecture 15
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
 
Lecture 13
Lecture 13Lecture 13
Lecture 13
 
Lecture 12
Lecture 12Lecture 12
Lecture 12
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 

Recently uploaded

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 

Recently uploaded (20)

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 

Lecture 2

  • 2.
  • 3. SHARE OUT 1. 3 job postings for the companies you want to work for 2. Research what qualifications you need to get that job 3. The company culture of the 3 companies you chose 4. Project ideas to add onto your resume
  • 4. AGENDA • Creating Projects Within Visual Studio 2010 • Explain the structure of a C# application. • Writing a C# Application • Print statements + Variables + Error Handling • Documenting an Application • Running and Debugging Applications by Using Visual Studio 2010
  • 5. CREATING PROJECTS WITHIN VISUAL STUDIO 2010
  • 6. PARTS OF A C# PROJECT • Solution: a container used by Visual Studio to organize one or more related projects. • When you open a solution in Visual Studio, it automatically loads all the projects that the solution contains. • Workspace: This is the space where you actually work on a part of your program.
  • 7. 1. CREATE A SOLUTION
  • 8. 2. ADD A PROJECT
  • 9. 3: YOU’RE READY TO CODE!
  • 10. COMPILING VS RUNNING • Compile-time is the time at which the source code is converted into an executable code (converting from C# language to byte language – the computer understands byte language) • Run time is the time at which the executable code has started running i.e. your output begins producing.
  • 11. STRUCTURE OF A C# APPLICATION • The first line of the program using System; - the using keyword is used to include the System namespace in the program. A program generally has multiple using statements. • The next line has the namespace declaration. A namespace is a collection of classes. The HelloWorldApplication namespace contains the class HelloWorld. • The next line has a class declaration, the class HelloWorld contains the data and method definitions that your program uses. Classes generally contain multiple methods. Methods define the behavior of the class. However, the HelloWorld class has only one method Main. • The next line defines the Main method, which is the entry point for all C# programs. The Main method states what the class does when executed. • The next line /*...*/ is ignored by the compiler and it is put to add comments in the program. • The Main method specifies its behavior with the statement Console.WriteLine("Hello World"); • WriteLine is a method of the Console class defined in the System namespace. This statement causes the message "Hello, World!" to be displayed on the screen. • The last line Console.ReadKey(); is for the VS.NET Users. This makes the program wait for a key press and it prevents the screen from running and closing quickly when the program is launched from Visual Studio .NET.
  • 13. PRINT STATEMENTS • Console.WriteLine(“your text”); • After the console prints your text, the cursor will start on a new line • Console.Write(“your text”); • After the console prints your text, the cursor will stay on the same line
  • 14. VARIABLES – 5 DIFFERENT DATA TYPES • int - integers (whole numbers) such as 0, -65 • double - decimals such as 19.99 or -19.99 • char - characters such as 'a' or 'B'. Char values are surrounded by single quotes • string - text, such as "Hello World". String values are surrounded by double quotes • bool - Boolean such as true or false
  • 15. VARIABLE SYNTAX • type variableName = value; int myNum = 15; myNum = 20; // myNum is now 20 Console.WriteLine(myNum); int myNum = 15; myNum = 20; // myNum is now 20 Console.WriteLine(myNum); int myNum; myNum = 15; Console.WriteLine(myNum); string name = ”Ruby"; Console.WriteLine(name);
  • 16. CONCATENATION • Concatenation: Combining a string with a variable string name = "John"; Console.WriteLine("Hello " + name); string firstName = "John "; string lastName = "Doe"; string fullName = firstName + lastName; Console.WriteLine(fullName);
  • 17. MORE EXAMPLES … int x = 5; int y = 6; Console.WriteLine(x + y); // Print the value of x + y int x = 5, y = 6, z = 50; Console.WriteLine(x + y + z);
  • 18. MEANINGFUL NAMES // Good int minutesPerHour = 60; // OK, but not so easy to understand what m actually is int m = 60;
  • 19. ERROR HANDLING • An exception is a problem that happens during the execution of a program. • try − A try block identifies a block of code for which particular exceptions is activated. It is followed by one or more catch blocks. • catch − A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception. • finally − The finally block is used to execute a given set of statements, whether an exception is thrown or not thrown. For example, if you open a file, it must be closed whether an exception is raised or not. • throw − A program throws an exception when a problem shows up. This is done using a throw keyword.
  • 20.
  • 21.
  • 22. WHY IS COMMENTING IMPORTANT? • For you to understand X amount of time later • For your colleagues to understand (marketing, development, etc.) • Can make code maintenance much easier, as well as helping make finding bugs faster. • Clients are able to use your code efficiently • Organization
  • 23. WHAT IS COMMENTING? • All programs should be commented in such a manner as to easily describe (in English) the purpose of the code and any algorithms used to accomplish the purpose. • A user should be able to utilize a previously written program (or function) without ever having to look at the code, simply by reading the comments. • Commenting is the "art" of describing what your program is going to do in "high level" English statements. Commenting is best done before actually writing the code for your program. • Comments are specially marked lines of text in the program that are IGNORED. • There are usually two syntactic ways to comment. • The first is called a single line comment and, as implied, only applies to a single line in the "source code" (the program). • The second is called a Block comment and refers usually refers to a paragraph of text. A block comment has a start symbol and an end symbol and everything between is ignored by the computer
  • 24. HOW TO COMMENT CODE INCLUDE • what the function does. • what arguments the function expects. • any known issues with the code. • up-to-date information. Information about code that has since been changed is of no use to anyone. • credit where credit is due. Make sure to credit anyone who contributed to the code! AVOID • unnecessary information. Don’t include anything not related to the code and avoid over explaining. • assuming the user’s knowledge. The documentation needs to be helpful to everyone, from experts to beginners. • confusing formatting. Doesn’t matter how much information is in the documentation if no one can read it. • ambiguous or hard to understand language. Documentation has been standardized to be written in English, so it is going to be used by non-native speakers of English as well. NOT HOW but… WHAT
  • 25. DOCUMENTING YOUR CODE (COMMENTS) /* The code below will print the words Hello World to the screen, and it is amazing */ Console.WriteLine("Hello World!"); // This is a comment Console.WriteLine("Hello World!");
  • 26. HOW TO COMMENT YOUR FILES • The first four lines of any program: • Full Name: • Date: • File Name: • Purpose:
  • 27.
  • 28. DEBUGGING APPLICATIONS IN VISUAL STUDIO
  • 29. SET A BREAKPOINT AND START THE DEBUGGER • Set a breakpoint and start the debugger • F5 (Debug > Start Debugging) or the Start Debugging button in the debug toolbar • The debugger runs to the first breakpoint that it encounters. If the app is not yet running, F5 starts the debugger and stops at the first breakpoint. • A breakpoint indicates where Visual Studio should suspend your running code so you can take a look at the values of variables, or the behavior of memory, or whether or not a branch of code is getting run. • You can set a breakpoint by clicking in the margin to the left of a line of code.
  • 30.
  • 31. NAVIGATE CODE IN THE DEBUGGER USING STEP COMMANDS
  • 32. INSPECT VARIABLES WITH THE AUTOS AND LOCALS WINDOWS • While debugging, look at the Autos window at the bottom of the code editor. • In the Autos window, you see variables along with their current value and their type. • The Autos window shows all variables used on the current line or the preceding line
  • 33. • Next, look at the Locals window. The Locals window shows you the variables that are currently in scope.
  • 34. • You can use a Watch window to specify a variable (or an expression) that you want to keep an eye on. • While debugging, right-click an object and choose Add Watch. • In this example, you have a watch set on the f object, and you can see its value change as you move through the debugger. • Unlike the other variable windows, the Watch windows always show the variables that you are watching (they're grayed out when out of scope).
  • 35. EXAMINE THE CALL STACK • The Call Stack window shows the order in which methods and functions are getting called. • The top line shows the current function (the Update method in this example). • The second line shows that Update was called from the Path.set property, and so on. • The call stack is a good way to examine and understand the execution flow of an app.
  • 36. EXAMINE AN EXCEPTION • When your code throws an exception, the debugger takes you to the line of code that threw the exception. • In this example, the Exception Helper shows you a System.Argument exception and an error message that says that the path is not a legal form. • So, we know the error occurred on a method or function argument.
  • 37.
  • 38. DISCUSSION • Why is this important? • How can this be useful to me? • How can I use this in my current job? • How can I use this in my future career? • What will I get out of this? • How is this used in the real world Regroup and discuss after…
  • 39.
  • 40. COMPLETE THE WORKSHEET WITH YOUR GROUP Regroup and discuss after…