Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What c# classes and functions can be used in razor?

Using ASP.NET MVC can be used the view engine Razor.

Razor let you use c# code after the @ sign.

As example

@if (Model.Category == "watersports")
{
    <p>Splash!!</p>
}

Furthermore you can use something like @DateTime.Now for get the current time. My question is: what functions can be used? From where Razor import them?

like image 581
Ricardo Polo Jaramillo Avatar asked Mar 03 '12 20:03

Ricardo Polo Jaramillo


People also ask

What is C language?

C is an imperative procedural language supporting structured programming, lexical variable scope, and recursion, with a static type system. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support.

What is C used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is -= in C?

-= Subtract AND assignment operator. It subtracts the right operand from the left operand and assigns the result to the left operand. C -= A is equivalent to C = C - A.


1 Answers

Any public class. They get imported with @using MyNamespace. You can also import them in the config file

<system.web.webPages.razor>

element.

like image 161
Otávio Décio Avatar answered Oct 28 '22 13:10

Otávio Décio