# Динамическое приведение типов(Dynamic Type Casting)

При динамическом приведении типов используется постфиксное выражение типа `as DesiredTypeName`. Vala добавит в этом месте допустимости такой операции - если это не так, то будет возвращен null. Однако при этом требуется, чтобы и исходный и конечный типы были ссылочными типами.

Например

```csharp
Button b = widget as Button;
```

Если по какой причине тип widget не Button или его потомок или не реализует интерфейс Button, то b будет null. Такое приведение эквивалентно:

```csharp
Button b = (widget is Button) ? (Button) widget : null;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vala.gitbook.io/vala/untitled/oop/dynamic-type-casting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
