The different flow control operators (if, switch, etc.) are the same as in C#; however, there is no foreach and there is a for...in construct. This is illustrated in this tutorial.
- [Instructor] The basic flow control operators…work exactly as they do in C#.…The ternary operator is available.…But Switch works as it did in C# before C# 7.…While and while do loops work as you would expect,…as does the for loop.…However there's no for each,…but there's something very similar which is the for in.…Let's look at an example.…Here's how you declare a dictionary in TypeScript.…
Here we have a as the key for value1,…b as the key for value2, and c as the key for value3.…We can iterate over the dictionary using the for in.…As you can see it begins with for and then we say…for the variable key in myDictionary,…and now we're going to write out to the console…the key and the value at the offset of myDictionary…using that key.…The result, as you would expect,…are the three values are recovered by their keys.…
In this course, Jesse Liberty reviews the fundamentals of TypeScript for the C# developer, including the built-in types, flow controls, and functions. He covers default, optional, and rest parameters; lambda functions; object literals; and the creation and use of custom classes. Plus, learn about other object-oriented features such as inheritance and interfaces. By the end of the course, C# developers should be well on their way to incorporating this flexible and powerful web programming language into their app development workflow.
- Setting up a TypeScript development environment
- Working with types and variables
- Using operators to control flow
- Working with parameters and functions
- Creating classes and objects
- Exploring TypeScript inheritance
- Working with interfaces