# this

The `this` keyword provides a way for the object instance that is currently executing code to refer to itself.

## this in Unity

In Unity, most custom code that we write is to create script components. Therefore, in Unity, `this` usually refers to the script component that is executing the current code. Common uses include accessing a different component, or identifying the associated gameObject.

```java
Vector3 pos = this.transform; //example of accessing a component

Destroy( this.gameObject);  //example of identifying associated gameObject
```

[MSDN Reference](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/this)

> The this keyword refers to the current instance of the class ...

The MSDN reference provides several usage examples


---

# 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://kdoore.gitbook.io/cs2335/f20_bkup_v2/c-language/c_language/this.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.
