How to use Collection inside Razor Syntax

In this chapter you will learn

  • How to use Collection inside Razor Syntax
  • Programming Example

How to use Collection inside Razor Syntax

A collection is a group of objects of the same type. There are mainly two common collections are used in razor, Array and Dictionary. You have learned Array in previous chapter so we will focus on Dictionary in this chapter.

Dictionary

A dictionary is a collection of key/value pairs and you can use it in programming as follow:


  • Output

    Results of the students are:
    Jack : 75
    Steven : 80
    Clark : 95

    Summary

    In this chapter you learned to use Dictionary in razor syntax. You are free to use any types of collection in razor syntax. In the next chapter you will learn creating Methods with parameter in Razor Syntax.


    Leave a Reply

    Your email address will not be published. Required fields are marked *