Razor syntax

Ratings:
(4)
Views: 322
Banner-Img
Share this blog:

Performing same example with Razor syntax :-

13

@ layout = null;
Var num 1 = 0;
Var num 2 = 0;
Var Result = 0;
If (is post)
{
Num 1 = request [‘T1’].As Int [];
Num 2 = request [‘T2’].As Int [];
Result = num 1 + num2
}

Design :-

2In the first example we declare variable of int type and conversion is done by using Convert . to int 32 (); method 2This is completely in C # syntax. Here C# syntax with Razor syntax. 2In IInd Method we completely used Razor syntax that is Declaring the variable using keyword, and performing conversion using as int () method.

Interested in mastering ASP.net Training?
Enroll now for FREE demo on ASP.net Training.

Conversion Methods in Razor Syntax :-

As Int () :-              convert the data to integer type . As Float () :-             convert the data to Float type As Decimal () :-           convert the data to Decimal type. As Date and time() :-  convert the data to  date time type As Bool ()       :-             convert the data to  Bool type To string ()     :-              convert the data to String type

Data type Comparison   Methods :-

  1. Is Int () 2compares the given data in integer type, return true. If the data belongs to integer type other vise return false.
  2. Is Float () 2compares the given data in F type, return true. If the data belongs to integer type other vise return false.
  3. Is Decimal () 2compares the given data in Decimal type, return true. If the data belongs to integer type other vise return false.
  4. Is Date time () 2compares the given data in Date time type, return true. If the data belongs to integer type other vise return false.
  5. Is Bool () 2compares the given data in Bool type, return true. If the data belongs to integer type other vise return false.

For indepth understanding click on

You liked the article?

Like: 0

Vote for difficulty

Current difficulty (Avg): Medium

EasyMediumHardDifficultExpert
IMPROVE ARTICLEReport Issue

About Author

Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.

Stay Updated
Get stories of change makers and innovators from the startup ecosystem in your inbox