C#
C#
C#
Fundamentals I
Course Code 109
Sri Lanka Institute of Information Technology
Jagath Wickramarathne
[email protected]
Lecture 2 - Learning C#
Basics
Introducing the .NET Platform.
cati
o
n
Soft
w ar
e
http://www.nickhalstead.com/wp-content/computer-user.jpg
08 January 2010
Software . . .?
http://patentu.blogspot.com/2007/03/what-is-software.html
08 January 2010
08 January 2010
Computer Programming
Languages
A programming language is a machine-readable artificial
language
designed to express computations that can be performed by a
machine, particularly a computer.
Programming languages can be used to create
programs that specify the behavior of a machine,
to express algorithms precisely, or as a mode of human
communication.
http://en.wikipedia.org/wiki/Programming_language
http://www.levenez.com/lang/
http://www.engin.umd.umich.edu/CIS/course.des/cis400/
08 January 2010
08 January 2010
What Is .NET?
Microsoft .NET, is a platform for developing
software.
You are building applications on:
Microsoft .NET (pronounced Dot Net).
You learn about the parts of .NET,
08 January 2010
PF I
PF
II
ITA
08 January 2010
http://cplus.about.com/od/introductiontoprogramming/a/cshbeginners.htm
10
08 January 2010
Institute
Sri Lanka
Arrayof bounds
Information technology
checking
at runtime
11
08 January 2010
12
08 January 2010
.NET framework.
Then a C# compiler.
Download
Sri Lanka Institute
of
Information technology
08 January 2010
14
08 January 2010
16
08 January 2010
C# Compilation Process
http://www.mastercsharp.com/article.aspx?ArticleID=90&&TopicID=4
17
08 January 2010
Where Do I Go Now?
First you have to learn to program in
C#.
Text Book
MSDN
Internet
E-books
Join The Forums
http://dotnetforum.lk/
Etc.
Sri Lanka Institute of
Information technology
18
08 January 2010
Writing a Simple C#
Program
Editor / IDE
Project Type
Notepad
Console Application
Windows Forms
Application
08 January 2010
19
C# - Console Applications
using Visual Studio 2008 Command Prompt
Step I
Open a notepad.
Step II
Write the following code and save as FirstProgram.cs.
Step III
Open Visual Studio 2008 Command Prompt.
Change the current directory to the place where you
save FirstProgram.cs.
Step IV
Type csc FirstProgram1.cs compile command.
Step IV
Run FirstProgram1.exe
Sri Lanka Institute of
Information technology
20
08 January 2010
21
08 January 2010
Demo One
How to create a C# console
application using Visual Studio 2008
Command Prompt.
22
08 January 2010
C# - Windows Applications
using Visual Studio 2008
Step I
Run Microsoft Visual studio 2008.
Step II
Create new project Windows Forms
Application
Step III
Design Interface / Form
Step IV
Compile
Step V
Run
Sri Lanka Institute of
Information technology
23
08 January 2010
Demo Two
How to create a C# Windows Forms
application using Visual Studio 2008.
Solution
Project
.EXE
24
08 January 2010
Demo Three
25
08 January 2010
With camel casing, the first letter of the first word is lowercase, and
subsequent words are capitalized.
bookTitle, employeeName, and totalCompensation.
Parameters, private fields, and local variables use camel casing.
26
08 January 2010
Commenting Code
These commenting techniques prove useful any time you want to comment
out a block of incomplete code to get a good compile or any other time you
want to leave a block of code in place temporarily.
The multiline and single-line comments are great for helping yourself or other
programmers understand your code.
Sri Lanka
XMLInstitute
documentation
commenting feature that is good for both reading code
of
08 January 2010
and providing
external 27
documentation.
Information
technology
Single-Line Comments
Multiline Comments
Multiline comment delimiters are the begin comment /* and end comment */ markers.
Anything between these two markers is considered a comment.
/*
* File Name: Program.cs
* Author: Nishani Ranpatabendi
*/
XML documentation comment supports tools that extract comments into an external XML document.
This XML can be consumed by tools or run through XSLT style sheets to produce readable documentation.
XML documentation comments start with a triple slash, ///, on each line.
///
///
///
///
<summary>
first method executed in application
</summary>
<param name=args>command-line options</param>
08 January 2010
29
08 January 2010
30
08 January 2010
31
08 January 2010
Summery
Introducing the .NET Platform.
Steps involved in C# program
development.
Computer Programming Languages.
What Is .NET?
Writing a Simple C# Program.
Commenting Code.
Identifiers and Keywords.
Convention and Style.
Getting Started with C# and Visual Studio
2008.
Sri Lanka Institute of
Information technology
32
08 January 2010
Reference
http://msdn.microsoft.com/en-us/vcsharp/bb798022.aspx
33