Skip to Main Content
ASP.NET Core MVC 2.0 Cookbook
book

ASP.NET Core MVC 2.0 Cookbook

by Jason De Oliveira, Engin Polat, Stephane Belkheraz
February 2018
Intermediate to advanced content levelIntermediate to advanced
668 pages
15h 18m
English
Packt Publishing
Content preview from ASP.NET Core MVC 2.0 Cookbook

Getting ready

Let's create a new file with the .ts extension, name it main-0, and write the following code in it:

interface Customer { 
    name: string; 
    email: string; 
    phone: string; 
} 
 
let customers: Array<Customer> = []; 
 
customers.push({ 
    name: 'Engin Polat', 
    email: 'engin@enginpolat.com', 
    phone: '0123456789' 
}); 

As you can see, Typescript allows us to define the interface in the code and add properties in it. Every property can have a type, and all assignments to that property must be that type. Otherwise, the Typescript tsc will throw an exception and will not transpile the Typescript code into JavaScript code.

Let's also write the following code and examine it:

class Product { public title: string; public price: number; private updatedOn: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET Core and Vue.js

ASP.NET Core and Vue.js

Devlin Basilan Duldulao
Mastering ASP.NET Web API

Mastering ASP.NET Web API

Mithun Pattankar, Malendra Hurbuns

Publisher Resources

ISBN: 9781785886751Other