Sunteți pe pagina 1din 51

AMR SWALHA

.NET Beginners Guide


Copyright © Amr Swalha, 2018

All rights reserved. No part of this publication may be


reproduced, stored or transmitted in any form or by any
means, electronic, mechanical, photocopying, recording,
scanning, or otherwise without written permission from the
publisher. It is illegal to copy this book, post it to a website, or
distribute it by any other means without permission.

First edition

This book was professionally typeset on Reedsy.


Find out more at reedsy.com
To my lovely father and mother. Thank you for everything :)
Contents

I Intro to C# and Basics

.NET Beginners Bootcamp Course 3


Introduction to .NET and C# 4
C# language basics 5
Setting Up Development Environment 5
C# Variables 8
C# Methods 9
C# Class 11

II Advanced C#

Iteration Statements 17
For Iteration 17
While Iteration 19
foreach Iteration 20
C# Classes In Depth 22
Constructor 22
Class Inheritance 24
Namespace 26
Interfaces 27
III Web Development With ASP.NET

ASP.NET Website Basics 31


Creating ASP.NET Websites with Visual Studio Code 31
MVC 33
Models 34
Views 35
Controller 38
I

Intro to C# and Basics

Learn about the history of C# and the basics of C#


.NET Beginners Bootcamp Course

Hello There! We hope you enjoyed this book. You can get the
full course on Udemy for only $9.99 from this link:
https://www.udemy.com/net-csharp-beginners-bootcamp/
?couponCode=KINDLE

3
Introduction to .NET and C#

C# was initially released back at 2000. It was designed to serve


as a multipurpose object oriented programming language. The
initial naming for C# was “Cool”! which is kinda cool! C# is
currently one of the most widely used programming languages
around the world.
C# is considered a strongly typed language, that is every thing
inside it must be declared and has a type. With C# you can
develop mobile apps, websites, IoT apps, and many other types
of solutions and apps. C# is a part of the .NET framework and
where it gets executed and run.
C# as an Object Oriented Programming language, you can
create classes and objects to hold your data for you and you can
pass values to these datatypes to have them processed. C# is
also filled with features that can easy your development process
and make it easier for you.

4
C# language basics

Setting Up Development Environment

Let’s start developing apps by C#. We will start by creating a


console application so we can run it and print out some data on
the screen for the user to see. You can either Install Visual Studio
or you can use Visual Studio Code to create a console app. Either
will be fine. For this section of this guide, we will be using VS
Code. Also, make sure you install the .NET Core SDK (Works on
Mac and Windows from this link:https://www.microsoft.com/
net/learn/get-started-with-dotnet-tutorial )
Now, let’s head over to VS Code and open a new folder to
have our project inside it. After Opening Visual Studio Code,
open the Terminal and run the following command to create
a new console application: dotnet new console. After that a
new console app project will be created for you. Notice how the
project structure in the left side:

5
.NET BEGINNERS GUIDE

Now, let’s run the console and let’s the results of this console
app. To do so, You can either hit F5 or from the menu Debug ->
Start Debugging. Notice that the output of the console is shown
in the Debug Console:

Notice the Hello World!

Also, you can pause the execution of the console to see the values
while debugging. To do so, you can place a breakpoint by clicking
on the far left inside the editor before the line number. Notice it
will place a red circle on the line:

6
C# LANGUAGE BASICS

and when you run the console app it will stop where you have
placed the breakpoint and show you the values:

Debugging can be very useful to see how the program is executing

7
.NET BEGINNERS GUIDE

C# Variables

A variable is a container for a value. We can store data inside


the variable and change it later on. There are different types of
variables that can store different types of data. For example, if
we want to store a number, we can use the int data type. If we
want to store a date, we can use the DateTime data type. Each
data type takes a certain amount in the memory so be careful of
defining too many variables which will cause your application
to fill memory and might crash.
Defining a variable in C#, we need to set the variable data type
then the name of the variable. For example, if we want to define
x as integer we do it as follow:

Notice how we first put the type of the varaible we want to define
before it’s name so we tell the compiler what type of variable this
is and what type of data to be stored inside it. Remember that
C# is strongly type language so fi you define a variable of type
integer you cannot store inside it a string, for example using
“5” (Five with double quotes) will generate an error. Unlike
JavaScript this will be okay!

So let’s add two variables X and Y to have two integer number

8
C# LANGUAGE BASICS

and sum them together so we can the result of their sum to be


printed on the screen. The code as follow:

int x = 5;
int y = 7;
Console.WriteLine(x + y);

And if we run the program we can see the following result:

The result of sum x, y

Always make sure the variables names are meaningful and easy
to understand.

C# Methods

Methods are a collection of code that we want to use again and


again. Instead of writing the same code multiple times. We
write it only on a single place and we call it as much as we like.
For example, if we want to calculate points for a bank account
we create a method for us to be reused again and again. If we
want to increase or decrease the amount of points for a certain
account we need only to change it in a single place and it will be
reflected across the code.

9
.NET BEGINNERS GUIDE

To define a C# method, we need to specify it’s access level,


return type, method name, and the parameters that this method
can accept as follow:

public void CalculatePoints() { }

The public keyword refers to the access level for this method.
Public indicates that this method can be accessed from the
outside world. Void is the return type and void indicates that this
method does not return any data. CalculatePoints refers to the
name of the method. The parenthesis refers to the parameters
that can be sent to this method. Parameters are the values that
can be sent to this method to be processed.

Now, let’s change our method a little bit to accept parameter


of type integer and return integer also. This method will take
the balance of the account and it will multiply it by 5 and return
the points:

public static int CalculatePoints(int accountBalance) {


return accountBalance * 5;
}

Note: We added static keyword to be able to access the method


inside the Main method.

Now if we call the CalculatePoint method notice that when we


pass any value it will multiply it by 5 and return the result for us.
Notice that the return keyword is responsible for returning the
value after the calculation is done. Now, let’s send a variable to
CalculatePoints and see the results:

10
C# LANGUAGE BASICS

static void Main(string[] args)


{
int balance = 100;
Console.WriteLine(CalculatePoints(balance));
}

Let’s examine the results:

As you can notice, the value we passed was multiplied by 5.


Now, you can also call the method multiple times not only once.
Methods will help you save time by writing the code in a single
place and access it as many times as you need.

C# Class

A class is a large collection of code. A class purpose is to hold


common code in one place. Also, it can be used to represent an
entity or a type such as a shape class that represent the different
shapes. We can add properties to a class to describe values inside
the class. Properties are like variables where you can use them
to store and retrieve data. Class also can contains methods.

Class can also contains methods. We usually assign an class


to represent a single entity such as a person or an object. For

11
.NET BEGINNERS GUIDE

example, let’s say that we are creating a university system and


this system needs to store data for students so we will create a
class that represent students and we will call it Student.

To create a class in C#, we add a new file with the class name
and the extension of that file is (.cs). So, let’s add a new class
inside our project and let’s add the following code inside the
class so we declare the Student Class:

public class Student


{
}

Notice to declare a C# class we need to add the “class” reserved


word so we declare it. We need also to specify the access modifier
so we can access it from inside the project or outside world.
“public” means anyone can access this from inside the project
or outside. After the class keyword we need to add the name of
the class so we can declare it.

Now, inside the class we can add methods or properties so we


can do operations inside the class. Let’s add a Name property so
we can store the name of the student inside it and later on we
can retrieve:

public class Student


{
public string Name { get; set; }
}

12
C# LANGUAGE BASICS

Now we also want to add a small method to great students. So


we will add the method “SayHello” to the class so we say hello
to the student. The following is the code inside the class with
the adding of the “SayHello” method:

using System;
public class Student
{
public string Name { get; set; }
public void SayHello(){
Console.WriteLine($“Hello, {Name}“);
}
}

Now, we have our class ready to store the name of the student
and we can say hello with his name. But how we can call the
class and store data and call the methods inside it. We can do
this by creating an object of the class. Creating an object of the
class will create a new location in the memory that stores the
data we have placed inside it. So, let’s create a new object of the
class. To do so, we place the name of the class first and then the
name of the object of the class. After that we add the equal sign
and then the name of the class as follow:

Student student = new Student();

This way we have created a unique copy of the class to contain


our own data for the student that we specify. We can create as
many objects as we desire. Now, how we can add values to the
class object we have created? To do so, we call the object name
and then the name of the property that we want to add value to

13
.NET BEGINNERS GUIDE

as follow:

student.Name = “John”;

This way, we are setting the value of the property inside the
class object. Also we want to call the “SayHello” method so we
print the hello message for the student. This is also possible via
the object we created as follow:

student.SayHello();

And if we checked out the result of the running the console, it


will be as follow:

So classes can contains a group of code that is related and it will


hold data that represent an entity.

14
II

Advanced C#

Get more deeper with C# and learn more complex


code. In this chapter we will take a look at Iteration
Statements, Arithmetic Operations, Interfaces, Class
Inheritance
Iteration Statements

Iteration Statements are used to iterate or loop over a certain


condition to do an operation more than once and stop when the
condition is met. Iteration statements are generally used to do
operation on a long list of data or to do a thing more than once.
There are many iteration reserved statements such as for, while,
do while, foreach. Each statements are executed more than once
until there condition to stop is met.
Let’s start first with the most basic and well known iteration
statement which is the for statement.

For Iteration

for is used to go over a code and make sure it’s executed more
than once and will stop as soon as the condition in the statement
are met. The following example are for a simple for that will be
executed 10 times and it will print on the console screen 10 hello
world.

for (int i = 0; i < 10; i++)

17
.NET BEGINNERS GUIDE

{
Console.WriteLine(“Hello World!“);
}

Notice the following inside the for statement. There is the


i variable which will store the value 0 at first and it will be
incremented each time the code inside the loop gets executed.
notice that at the end we use the i++ which indicates that i will
be increased each time by 1. You can even increase the i more
than 1 each time the loop gets executed.

If you also look closely to the code you will notice that there
is a condition. The i < 10 indicates that the loop will continue
unless the value of i is greater than 10. When the condition is met.
The loop will run for 10 times. That is because we are staring
from the zero value and increasing the i value until it reach 10.

Also, we can use the i as an indicator at where the loop is


currently is being executed. We can have the i printed to the
console screen so we see where is the loop is running:

for (int i = 0; i < 10; i++)


{
Console.WriteLine($“Loop is currently at ${i}“);
}

We can also go the other way with the for loop. We can go from
higher number to lower. To do so, we invert the condition and
the statement that controls the value to be decreasing the value

18
ITERATION STATEMENTS

not increasing it. See the following example:

for (int i = 10; i > 0; i—)


{
Console.WriteLine(“Hello World!“);
}

This statement will run for 10 times as the previous one. But it
will take the i value from higher to lower. These types of loops
can be used to make sure that we are not out of range for an
element or a type.
But what if we made a mistake and made the for statement
without an increment condition. What will happen? This way
we will never meet the condition to go out of the loop and the for
loop will keep going. This case is called infinte loop. The loop
that never ends. Be careful of creating of a such loop or it will
make your program unusable and always stops to execute the
loop:

for (int i = 10; i > 0; i =1)


{
Console.WriteLine(“Hello World!“);
}

While Iteration

While loop is similar to the for loop. It has a condition and


as soon as the condition is met it will stop executing. The
While loop is different than the for loop in the way it handle

19
.NET BEGINNERS GUIDE

the increasing of the variable to check for condition. It’s usually


placed inside the while loop not outside or in the decoration of
the statement. Let’s see the following example of a simple While
statement:
int x = 0;
while (x < 10)
{
Console.WriteLine(“Hello World!“);
x++;
}

So the previous code will run 10 times before it’s get termi-
nated. Note that if you do not include the increment of the x
inside the while it will become an infinite loop.

foreach Iteration

foreach is also similar to the other iteration statements. But it


does not include a condition. This statement will go through a
list of element’s until the last one. We don’t need a condition
to control it. It will stop when it reaches the last element inside
a list. The following is an example of a while statement going
through a string variable and print out each letter on the console:

string word = “Hello World!“;


foreach (var character in word)
{
Console.WriteLine(character);

20
ITERATION STATEMENTS

In the previous code, we can see that the we will go into each
letter inisde the word variable and print it out. When using the
foreach iteration, we don’t need to set a condition for the loop to
stop, it will stop when it reach the last element inside it. Foreach
is better used with list of elements or items to go through them
and do some work on them.

21
C# Classes In Depth

Now, let’s get deeper with C# Classes as they are used a lot with
the C# applications development as a holder of data and to do
operations on them. We will first start with the Constructor of
the class, where we place our initial data and do operations as
soon as we create a new instance of the class. And then, we will
continue with the class inheritance. And we will finish off with
Namespaces where we can use them to organize classes.

Constructor

Constructors are methods that are called first thing when we


create an instance of our class. We can use this method to pass
initial data to be stored on the class properties and also do initial
work when creating a new instance of the class. This can be
helpful if we want our class to have some data as soon as we
create an instance of it.
To create a constructor, we add a method to our class that has
the same name as the class and we set the access modifier that
we desire on it. Usually we set it to public so anyone can use it

22
C# CLASSES IN DEPTH

and access it.

public class Student


{
public string Name { get; set; }
public Student(){
Name = “Joe”;
}
}

Notice inside the constructor we set the property Name value


initial value. We can also pass the value to the Name property
via a parameter in the constructor so each time we create a
new instance of the class we have to pass a value for the Name
property:

public Student(string name){


Name = name;
}

Now the object we create of this class will look like this:

Student student = new Student(“Joe”);

As you can see from the previous example, you now need to pass
a data to be stored inside the property in the class. This way we
can always guarantee that there is a data inside our class when
someone creates an object of it. But what if we want to allow
also the class property to be empty and also allow it to store

23
.NET BEGINNERS GUIDE

data inside the property? We can do an overload of the class


constructor to allow also to create objects of the class without
the need to pass initial data:

public class Student


{
public string Name { get; set; }
public Student(){ //An empty constructor

}
public Student(string name){
Name = name;
}
}

Now you have two options to create a new object of the class.
You either use the empty constructor and pass no data or use
the constructor which allows the value to be passed:

Student newStudent = new Student();


Student student = new Student(“Joe”);

Class Inheritance

Class inheritance is the way that we use the class to give it’s
property to child classes instead of repeating them. For example,
we can create a shape class that has two property one for area

24
C# CLASSES IN DEPTH

and another for color. Then, we can create a square class that
inherit the shape class and now we have the property area and
also color available for us to be used. Next, we can create another
class for a circle and also we can inherit the shape class and also
have the property that we need without rewriting them again.
To inherit a class, we place it’s name with a colon before it on
the child class as follow:

public class Shape


{
public int Area { get; set; }
}
public class Square : Shape {

Now if we create a new object of class Square, we can access it’s


property Area from the parent class Shape:

Square square = new Square();


square.Area = 10;

Not that only, we can also create methods inside the parent class
and it will be visible for us in the child class as well. For example,
if we add the PrintArea method in the parent class it will allow us
to print the area value from all our child classes without writing
the same method again and again:

25
.NET BEGINNERS GUIDE

public class Shape


{
public int Area { get; set; }
public void PrintArea(){
Console.WriteLine($“The Area is {Area}“);
}
}
public class Square : Shape {
public void PrintMessage(){
Console.WriteLine(“This is a Square!“);
PrintArea();
}
}

Namespace

Namespaces are used to group related classes together and keep


them in a known place. Namespaces can lower the amount
of classes in the app to be referenced. So you just call the
namespace that you need and reference it’s classes. Creating
a namespace is easy you need to add the reserved keyword
namespace and the name of it and add two curly braces around
the classes you want to be included in the namespace:

namespace School
{
public class Student
{
}

26
C# CLASSES IN DEPTH

public class Subject


{
}
}

So, if we want to use the classes inside the School namespace we


have to use the using keyword with the name of the namespace
to have the class imported to use them with our code or we will
get an error:

So at the top of the class file reference the namespace so you


can remove the error and be able to use the classes inside the
namespace:

using School;

Interfaces

Interfaces are used to program classes in a certain rules. For


example, when you create an account class you want any pro-
gramer to add the AddToBalance method and SubtractBalance
on each account class they create so any account class that is

27
.NET BEGINNERS GUIDE

created have these methods so you can always guarantee that


the same code is written on each class.
Interfaces are generally a good programming practice and you
should always create an interface that represent your classes in
case any one want to create the same class that you created you
can guarantee that any future changes can be reflected on these
classes.
Interfaces have methods and also can hold property. Just
remember that you don’t need to specify an access modifier
for each method. When implementing an Interface, make sure
to implement all methods and property or you will get an error.
Inter

28
III

Web Development With ASP.NET

You can create websites using ASP.NET and C#. ASP is


short for Active Serve Pages. It’s one of the well known
web development framework and many sites around
the world use it such as StackOverFlow and Bing.com
ASP.NET Website Basics

Creating an website with ASP.NET is quite simple these days and


only requires you to have the dotnet cli installed. In the old days,
you needed visual studio and a good amount of time to create a
website with old technology such as Web Forms. In this chapter,
we will take a look at how we can create an website with ASP.NET
using Visual Studio Code. Next, we will create some pages with
ASP.NET MVC Razor. And finally, we will look at the Web API
and how we can create an API controller.

Creating ASP.NET Websites with Visual Studio Code

To create a new ASP.NET Website using Visual Studio Code, go


to Visual Studio Code -> Open -> Create a new folder and open
it. From View Menu select Terminal. Now you will be presented
by the terminal window which allows you to call in the dotnet
command line and create a new website. now type dotnet new
mvc to create a new MVC site. After a successful command you
will be presented with the following project structure:

31
.NET BEGINNERS GUIDE

The structure of ASP.NET MVC Site

Now, to run the site hit F5 on the keyboard or select Debug ->
Start Debugging. Notice it will ask you to select an environment
so select .NET Core and also it might tell you it needs to add
configuration to help debug the project. Select add configuration

32
ASP.NET WEBSITE BASICS

as well. Now when you run the site, it will open a new tab inside
the browser and notice that the address of the site refers to
“localhost” which is the current locally debugging environment.
The result should be something similar to this:

ASP.NET Website running inside the browser

Notice that my website is not enabling https for smoother


development experience. You can disable the settings from
inside the project.

In the next Section, we will learn more about MVC and how
can edit the pages and create new pages.

MVC

33
.NET BEGINNERS GUIDE

MVC is a well known design pattern for web pages. Where we


have a separation between different layers of the application.
First we have the Model, which represent the entities and
what data we want to be displayed and transferred. The View
represent the visual elements of the web pages that we want
to be shown for the end user. The Controller are the connector
between the models and the views and it contains our business
logic.
The main point with MVC is the separation of concern. Where
every layer is responsible for something and will not hold any
extra logic. MVC can make your work much better and will help
you create dynamic sites that can accept changes and can be unit
tested more easily.
Now let’s get more deeper with ASP.NET MVC and see the
different parts and how they connect to each other and exchange
communications.

Models

Models represent the data holders inside the MVC site. Each
model represent an entity that relate to a unit of data that we
want to store and retrieve such as Employee information. We
use the models to represent this entity as class so we can work
with it to save data and do operations on the same data.
Models are usually placed inside the Models folder. And can
be grouped in a sub folder. Let’s add a new folder inside the
models folder and call it Employees. Inside this folder we will
add an EmployeeInfo.cs file so we can store the information

34
ASP.NET WEBSITE BASICS

for the employee. Also, we will add properties for this class
(Name, DateOfBirth, Email) so we can store information about
the employee. We will be using this model in the next part of
this chapter:

using System;
public class EmployeeInfo
{
public string Name { get; set; }
public DateTime MyProperty { get; set; }
public string Email { get; set; }
}

Views

Views are the visual part of our application. It’s where we place
our HTML code to render the controls for the pages so the user
can interact with our website. Also, inside the views we can
use Razor to apply application logic to the visual part of the
application for example to hide a certain section of the page if
the user does not has a certain permissions. Razor is the syntax
we can use inside the Views to write C# code inside the view file.
The views file are ending with cshtml which represent Razor
views file.
Inside the Views folder, we have some views already declared
for us. Such as the Home and the Shared views. Views can be
shared and reused again. If we open the Index view inside the
home folder we will see a lot of html created by default. Let’s
Delete all of it so we can work with a clean page. Now, let’s Add

35
.NET BEGINNERS GUIDE

an H1 element with the title of “Employee System”. We should


see the following result in the browser:

Our employee system inside the browser

What if we want to display the current date and time inside the
home page? How is that possible? We can do it via Razor. To
write the Razor code we add the @ sign in front of the code that
we want to place which is DateTime.Now to show the current
date time:
@DateTime.Now

Now when we run the site we will see the following result:

36
ASP.NET WEBSITE BASICS

Using Razor Inside the view

So now we have the date time printed out with C# code inside
the view file. We can also do more C# code inside the Razor view.
Let’s add an if statement inside the code so we check a value of
x variable if it is greater than 5 we will write on the page that x
is greater than 5 otherwise we will print that it’s less than 5:

@{
int x = 6;
if(x > 5)
{
<span style=“color:red;“>X is Greater than 5</span>
}
else
{
<span style=“color:red;“>X is less than 5</span>
}

37
.NET BEGINNERS GUIDE

Notice that we can add a block of code using the @ sign along
with the curly brace so we add a code block inside the Razor view.
And we can also write html elements to the Razor page via the
C# code.

Controller

The controller is the connector between the views and the


models. It’s where we place our business logic to be applied
both on the models and the views. Controllers are a class that
inherit the Controller class. Controllers have actions on them,
which are methods that’s receives requests from the browser
and process them. Actions can either return results or return
views to be displayed on the browser. Actions can hold business
logic and process models before they are sent to the view to be
displayed.
Let’s examine the following action inside the home controller:

public IActionResult Index()


{
return View();
}

38
ASP.NET WEBSITE BASICS

This Action is returning a view which is the index.cshtml view.


Notice that the return type is IActionResult and the return
statement is returning the view. By default, the Action will
return the view of the same name of the action. That is, it will
look for the Index view file inside the Home Folder in the Views
folder. You can set the name of the view differently if you pass
to the View Method a new name as a parameter.

Actions are not only for returning views. It can be used


also to return models and data to the view. And do operation
on these models and represent the data on the view. Let’s
add a new Controller inside the Controller folder and name
EmployeeController. You can do this quickly by copying the
HomeController and rename the Controller class file. Your
controller code should look like this:
public class EmployeeController : Controller
{
public IActionResult Index()
{
return View();
}
}
Now, let’s head over to the views folder and add a new folder
and name it Employee. And let’s add an index view file with
some title inside it. Your code should look like the following:
@{
ViewData[“Title”] = “Employee List”;
}
<h1>Employee List</h1>
<br/>
<br/>

39
.NET BEGINNERS GUIDE

Now, if you run the application inside the browser and go to


/Employee url you will be presented with the following:

Our new controller is up and running

After we have successfully created our controller and connected


it to the view. Let’s connect it to the model and send data from
the action to the view. To do so, we will create a new object of
the EmployeeInfo class and pass it to the view. We will pass it to
the View method so it will be rendered inside the view:
public IActionResult Index()
{
EmployeeInfo employee = new EmployeeInfo();
employee.Name = “Joe”;
employee.Email =“joe@work.com”;
employee.DateOfBirth = new DateTime(1980,1,1);
return View(employee);

40
ASP.NET WEBSITE BASICS

Now, how are we going to tell our view about the EmployeInfo
model so it render it’s data? To do so, we need to define our
model inside the view file:

@model EmployeeInfo;

This way we are telling the view that the model we will be using
of type Employee info. Inside the view we will be referencing.
And now we can access it’s properties via Model variable inside
the view. So, let’s add the data from the model inside our view
as follow:

Employee Name:@Model.Name <br/>


Employee Email:@Model.Email <br/>
Employee Date Of Birth:@Model.DateOfBirth

So now we will be rendering the values of the object we pass to


the view so the user can see them when he opens the web page
as follow:

41
.NET BEGINNERS GUIDE

The data of the view rendered with the model

But what if we want to render a list of employees data on the


page? We can also pass a list of objects to the view to be rendered.
To do so we need a list of Employee info and to enumerate
through the list and print it out on the screen as follow:
List<EmployeeInfo> employees = new List<EmployeeInfo>();
for (int i = 0; i < 10; i++)
{
EmployeeInfo employee = new EmployeeInfo();
employee.Name = “Joe”;
employee.Email = “joe@work.com”;
employee.DateOfBirth = new DateTime(1980, 1, 1);
employees.Add(employee);
}
return View(employees);

And now inside the razor view we will make it as a list and do

42
ASP.NET WEBSITE BASICS

a foreach on the list of the elements to be rendered:

@model IEnumerable<EmployeeInfo>
@{
ViewData[“Title”] = “Employee List”;
}
<h1>Employee List</h1>
<br/>
<br/>
@foreach(var emp in Model)
{
<span>Employee Name:@emp.Name</span> <br/>
<span>Employee Email:@emp.Email</span> <br/>
<span>Employee Date Of Birth:@emp.DateOfBirth</s-
pan>
}

Now the result will be the following on the screen:

43
.NET BEGINNERS GUIDE

44

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