# Guid.Empty and Guid.NewGuid

> The C# Guid statics. `Guid.Empty` is the all-zero Guid constant, spelled without parens; `Guid.NewGuid()` mints a fresh unique Guid. Guid.Empty pushes down into SQL predicates; Guid.NewGuid() is in-memory only.

<!-- id: function-guid-statics · area: function · stability: stable · html: https://osysharp.com/reference/function/guid-statics/ -->

## Summary        {#summary}
`Guid.Empty` is the all-zero Guid (`00000000-0000-0000-0000-000000000000`) — a constant, spelled **without
parens** exactly like C#'s static property. `Guid.NewGuid()` mints a fresh, unique Guid on each call. Both
are typed `Guid`.

## Signature      {#signature}
```osy syntax
Guid.Empty        // the all-zero constant (a property — no parens)
Guid.NewGuid()    // a fresh, unique Guid (a factory call)
```

## Description    {#description}
`Guid.Empty` is a deterministic constant. It is the idiomatic sentinel for an unset Guid — e.g. guarding a
reference before use:

```osy syntax
if (ownerId != Guid.Empty) { … }
```

Because it is a constant, `Guid.Empty` **pushes down into SQL** — it is usable inside a query predicate
(`Widget.Where(w => w.Id != Guid.Empty)`), where it renders as the zero-uuid literal.

`Guid.NewGuid()` is **non-deterministic** (a new value every call), so — like the crypto/random generators
— it runs **in memory only** and has no SQL push-down form; calling it inside a query predicate is an error.

`Guid.NewGuid()` is the faithful C# spelling and the single way to mint a Guid (it replaced the earlier
`Security.NewGuid()`).

### `Guid.Empty` or `Guid.NewGuid()`? — the parentheses are enforced   {#parens-enforced}

Swapping the two spellings is an error, in both directions, exactly as it is in C#:

```osy syntax
Guid.Empty()      // error — `Guid.Empty` is a property, not a method
Guid.NewGuid      // error — `Guid.NewGuid` is a method; call it with parentheses
```

The distinction is not decoration: `Guid.Empty` is a value that is always the same one, and `Guid.NewGuid()`
mints a new value every time it runs. The parens are how a reader tells those apart at a glance, so the
compiler holds you to them. The same rule covers every parenless member of the standard library —
`TimeSpan.Zero`, `DateTime.UtcNow`, `DateTime.Today`, `DateTimeOffset.UtcNow` and the `DurableClock` reads.

## Examples       {#examples}
```osy title="sentinel guard + minting" test app=guid-statics
Guid PickOwner(Guid requested) {
  if (requested != Guid.Empty) {
    return requested;          // caller supplied one
  }
  return Guid.NewGuid();       // otherwise mint a fresh owner id
}
```

## See also       {#see-also}
- [String interpolation & format specifiers](https://osysharp.com/reference/function/string-interpolation/) — Guids stringify through the same value coercion
