var Firstname = "Terry" and show with @firstName
var Firstname = "Terry"
@firstName
Just a simple variable - create and show.
@inherits Custom.Hybrid.RazorTyped @{ var firstName = "Terry"; } Name: @firstName
@inherits Custom.Hybrid.RazorTyped @{ var age = 27; var birthday = new DateTime(1999, 09, 09); } Age: @age <br> Birthday: @birthday <br> Birthday nicer using ToString("d"): @birthday.ToString("d") <br> Birthday as ISO ToString("yyyy-MM-dd"): @birthday.ToString("yyyy-MM-dd")
@inherits Custom.Hybrid.RazorTyped @{ var dogs = new string[] { "hound", "dackel", "doggy" }; } <div> Dog Count: @dogs.Length <br> Dog[0]: @dogs[0] <br> Dog First (with LINQ): @dogs.First() <br> Dog Last (with LINQ): @dogs.Last() <br> </div> <ol> @for (int i = 0; i < dogs.Length; i++) { <li>Dog @i: @dogs[i]</li> } </ol>