You are on page 1of 47

Microsoft Visual C# . .

net
. C++ Microsoft Visual Studio 1 C# 5002
5 Microsoft Visual Studio 2010 C#
. C# 3 Visual Studio 2008 Lambda LINQ
. C# .
Dynamic .
. .net
(Task Paralle Library)TPL . TPL
.
Visual Studio 2012 .net 5.2 .
MVC .

: Visual Studio
Visual
Application
Visual
Build Run
Visual

cmd
Hello Word
C#
Keywords

:

;)(console.ReadKey
Switch

: math

:
FullName

: )(else , if

if

11

][Array
Array
Object

21

: foreach

23

: C# Random



Random Password Dynamic

24

:
do , while
for

27

: try catch finally

31

: Convert
Data Type

41

: Method

42

Method

: Visual Studio 2012

.NET

. 2112
.NET 4.5
.

1.1
File New Project

1.1

C# .NET 4.5

()1

Visual Studio 2012 :


1.2 Application .

1.5

Application .
Windows Form Application

WPF Application
CMD
Console Application
DLL
Class Library
Visual C# . Templates .NET Framework 3.3
Windows7 . Sort By Application .
Name .
Location Default .
C# .NET 4.5

()2

Solution Name Solution


.
Create directory for Solution .
Add to source control
( )

1.3 .

1.3

1.4 .

. .

1.5

C# .NET 4.5

()3

1.3 .

1.2

Using System namespace


.
namespace Program Main .
class Program Main
Main Ram
.
C# ()Object
. C#
C# .
1.1 Build Run .

C# .NET 4.5

()4

BUILD Build
Solution Visual studio EXE
Debug . Debuger Syntax
.
Start .
:
Build Solution F6 .
Run Solution F5 .
--------------------------------------------------------------------------------------------------------------------------- 1.7 Visual Studio .

Errors , Warnings , Message


Visual Error . Description
Error .
Warning 99% Warning
C# .
Message

Visual Studio 2012
.


C# .NET 4.5

()3

: Cmd

Console Application.
Visual Studio 2012 Console Application
.Net FrameWork 3.2 .
Hello Word Ok ( )5.1

5.1

C# .NET 4.5

()6

Main .


Main String .
C# .
SayHello SayHello

Console console Property Method
.
Console WriteLine
( 19 Constructor) WriteLine constructor 11
( )String Value SayHello string
Hello Word .
ReadKey
.
Build Stard
C# .NET 4.5

()7

2.2 .

5.5


cw Tab ;( ) Console.WriteLine .
String AzimyPc :
(;) .

camel Captain
.SayHello:
C# .
Namespace

Class

Method

C# .NET 4.5

()8

C#
C# . C#
.

Int Age; Age = 25


Long count; count = 2870
Flot X; X = 0.5
Double X; X = 1.5
Decimal Price; price = 1000000
String Name; Name = Foad
Bool have; have = True

) (
35

45

) (

35

) (

45

) (

151

14

14

int
long
flot
double
decimal
string
char
bool

Keywords
. 77 C#
. Keywords
abstract
as
bace
bool
break
byte
case
catch
char
checked
class
const
continue
decimal
default
delegate

)9(

do
double
else
enum
event
explicit
extern
false
finally
fixed
floot
for
foreach
goto
if
implicit

In
int
interface
internal
is
lock
long
namespace
new
null
object
operator
out
override
parame
private

protected
public
readonly
ref
return
sbyte
sealed
short
sizeof
stackalloc
static
switch
struct
string
this
throw

true
try
typeof
unit
ulong
uchecked
unsofe
ushort
virtual
void
volatile
while

C# .NET 4.5

AND
OR
( )

()
++
-!
+
++
-*
/
%
+
>
=>
<
=<
==
=!
&&
||
=




NOT

AND
OR

1-Division 2-Relational
C#
.

X Y .
C#
)

+ sin

( cos

(1) 2

C# .NET 4.5

!2

!1

( ) = 0 +

=1

=1+

(1 +

()10


:2 .
Calculator.
Main int X 11
Y 3.
3.1

3.1

: x y ;() Console.WriteLine .
3.2 .

3.5

C# .NET 4.5

()11

(*) ( )/ ( )- X Y .
2

;))(int.pars(console.ReadLine

C#
String .
int.pars string int .
3.3 .

3.3

3.3 .
10 Enter.
Y Enter

C# .NET 4.5

()12

:2 switch
.
Dynamic
( )+,-,*,/ Visual
Set.
Switch.
Switch .
3.4 Switch .

) ( switch
{
": "case
( cace )break
;break
default:
;break
{

3.5

C# .NET 4.5

()13

3.3 .

3.2


9 int
11 x 4 Y 2 .
3.1 .

C# .NET 4.5

()14

int double
( + -*)
double
.
3.7 int double .

3.3


3.1

3.1

C# .NET 4.5

()13

Math

.
Visual Math .
.
3.9 .

3.3

.
:
X Y .
14
X Y

: Math Switch .
C# .NET 4.5

()11

:
.
.
5.1

FullName .
Solution .
Solution Add Project

Set
Set As StartUp Perjet Set
Solution
Run.

C# .NET 4.5

()17

ifelse

.
MTA .

C# if else .
Developer
( ) ...
.
AccessCart

.

AccessCart .
.
Syntax 3.1 .

2.1

C# .NET 4.5

()11

Password
int Password
Password If ==
( )2333 Password
( )2333
Password ( )2333
Visual studio

if
.
if .

3.2 .

C# .NET 4.5

()19

else if Password =! ) (2353


( )2333 .
3.3 if ( ) .

Name AccessCart .
Password ( )2333
AccessCart Name
Name Passeord .
if .

C# .NET 4.5

()21

: ][Array

) ) Data Type .
11 Ram
.
Array .
Zero Base
Data ...
.
Yaser
1

Nader
7

Morteza
1

Ali
3

Gavad
4

Mohammad
3

Saeed
2

Amir
1

Foad
1

Array .
1.1 Array .

C# .NET 4.5

()21

Name1 ListName
. ] [
] [ .
;} string[] ListName = { Name1, Name2, Name3, Name4, Name5

Object
C#
.
)static void Main(string[] args
{
;int Age = 20
;"string Name = "Foad
;decimal Price = 2500000
;"var LastName = "Azimy
;} object[] List = { Age, Name, Price, LastName
;)]Console.WriteLine(List [3
{

List ListName

] [0 , 1 , 2 , 3 Array

C# .NET 4.5

()22

: foreach
Foreach object
.
foreach .
1.1 foreach .

foreach

Foreach object item ListName


item

foreach Tab .

C# .NET 4.5

()23

: C# Random
Random
Random Random
Random New int

Run
Random
1 111
Guid
Guid

Guid .
--------------------------------------------------------------------------------------------------------------------------- RandomClass
7.1

3.1

C# .NET 4.5

()24

7.2

41443111
:

.
:

int Min value 111 int max value


Random .
:

11
:

...
1


121 String

( 11111 ) 91111

C# .NET 4.5

()23

.

7.3


12123197

3.3

Password Dynamic
. else if
Random 7.4 .

:
Your Passwor:1306
?Plaese Enter Password
1306
C#.NET 4.5

C# .NET 4.5

()21

:
C#

do, while .
true fales
Close
. 1.1 while .
:
Your Passwor:1306
?Plaese Enter Password
1306
C#.NET 4.5
Your Passwor:3247
?Plaese Enter Password
3247
C#.NET 4.5


close

For
Password
Password Password
.
Temp .

C# .NET 4.5

()27

1.2 For .

:
?Plaese Enter Password
8954
1:Bad
?Plaese Enter Password
2578
2:Bad
?Plaese Enter Password
1234
3:Good

Password

1.5

for .

For int i ( 1 ) i( 4 ) i ( )
foreach .

C# .NET 4.5

()21

Console
console Property ForegroundColor consoleColor
cmd .
1.3 console .

Bad Good
.

: ResetColor .

: ConsoleKeyInfo
consoleKeyInfo

Cmd .
Q

ConsoleKeyInfo

C# .NET 4.5

()29

Keyinfo .
9.1 .

3.1

Esc
consolekeyinfo
.
Key k
ConsoleKey K
ConsoleKeyInfo Set

ConsoleKey .

ConsoleModifiers

ConsoleModifiers .

C# .NET 4.5

()31

ConsoleModifiers Alt , Shift , Home , Esc


Modifiers k Modifiers
ConsoleKey ConsoleModifiers .
Esc
Modifiers Alt + Shift Q
9.2 .

3.5

Alt + Shift + Q .

C# .NET 4.5

()31

console.Beep
Console
Beep
.

ConsoleBeep int frequency


() ( duration) .

311 111 .

C# .NET 4.5

()32

ConsoleBeep(); :
. Music
.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace Music
{
class Program
{
static void Main(string[] args)
{
while (true)
{

ConsoleKeyInfo Clik;
Clik = Console.ReadKey();
switch (Clik.Key)
{
case ConsoleKey.P:
Console.Beep(1000, 200);
break;
case ConsoleKey.O:
Console.Beep(900, 200);
break;
case ConsoleKey.I:
Console.Beep(800, 200);
break;
case ConsoleKey.U:
Console.Beep(700, 200);
break;
case ConsoleKey.Y:
Console.Beep(600, 200);
break;
case ConsoleKey.T:
Console.Beep(500, 200);
break;
case ConsoleKey.R:
Console.Beep(400, 200);
break;
case ConsoleKey.E:
Console.Beep(300, 200);
break;
case ConsoleKey.W:
Console.Beep(200, 200);
break;

)33(

C# .NET 4.5

case ConsoleKey.Q:
;)Console.Beep(100, 200
;break

default:
;Console.ForegroundColor = ConsoleColor.Red
;)"]Console.WriteLine("Plaese Any Key Perss Only [P.O.I.U.Y.T.R.E.W.Q
;)(Console.ResetColor
;break
}
}
}
}
}

P.O.I.U.Y.T.R.E.W.Q
frequency duration
.

cmd
cmd
11
C#
.

C# .NET 4.5

()34

stringFormat
.

Visual Error

String
Zero Base
StringFormat .

Name 1 .

C# .NET 4.5

()33

Visual Studio Error


RunTime
Visual Studio Visual Syntax
Visual Error RunTime
Visual
Debug .
Error Name ,Family
Age
C# \n NewLine
Cmd .

C# .NET 4.5

()31

C# Environment
NewLine \n

C# .NET 4.5

()37

try catch finally


visual



Age
Visual .

C# .NET 4.5

()31

Age
Age X age

String int
.


try try catch finally
try Tab

C# .NET 4.5

()39

try catch Exceotin


Ex.Message CW .

finally ;)( console.ReadKey



try try
try .

C# .NET 4.5

()41

: Convert
Data Type
.
C# ( )String

11 Password int ;)(Console.ReadKey
Password )( int.Pars string int
.

;))(int Password = int.pars(console,readKey

)( Pars
convert
Data Type
.

:
13 X1Y1
XY
String Convert
int

Convert
Data Type

C# .NET 4.5

()41

: Method
) (Method
C#
Calss ( )Property ( )Method
.
... ( )Property
...( )Method .
Foundation Property Method C#
Method .

Method Add X,Y int

)( Console.WriteLine
Method ()public
( )static ) (void.
Method Add mine
X , Y int

C# .NET 4.5

()42

You might also like