# Setter

A method or property part that changes a value, often checking it first.

## What is **Setter**?

A **setter** is a method (or property part) that changes a value in an object. A good setter checks the new value before accepting it.

```csharp
public int Temperature
{
    get => temperature;
    set
    {
        if (value < 5 || value > 30) throw new ArgumentOutOfRangeException(nameof(value));
        temperature = value;
    }
}
```

Level: Apprentice · [More OOP terms at this level](https://www.ask-codey.com/glossary/subjects/oop/apprentice)

Updated: September 27, 2026

## In other subjects

- [Setter in C#](https://www.ask-codey.com/glossary/setter-c-sharp)
- [Setter in Java](https://www.ask-codey.com/glossary/setter)
- [Setter in JavaScript](https://www.ask-codey.com/glossary/setter-javascript)

Source: https://www.ask-codey.com/glossary/setter-oop
