---
title: N4Segment
summary: API reference for N4Segment.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-15
library: SAIF.Framework.Common.Files
reference_type: package
---

# N4Segment

`N4Segment` models the X12 N4 party geographic-location segment, used after `N1Segment`/`N3Segment` in 837/835 transactions to carry a party's city, state, and postal code. On `Fill()`, a postal code longer than five characters is split into a five-digit `ZipCode` and a `ZipCodeExtension`, and the two are concatenated back together on `Build()` ([BR-049](../../business-rules.md#br-049-n4-postal-code-split-into-zip-and-extension)).

## Purpose
- Represents the N4 segment identity via `SegmentId` returning the literal `"N4"` ([BR-020](../../business-rules.md#br-020-first-element-is-the-segment-identifier)).
- Carries `CityName` and `StateCode`, the party's city and state.
- Splits a postal code longer than five characters at parse time into `ZipCode` (first five characters) and `ZipCodeExtension` (the remainder), and rejoins them into a single element value on `Build()` ([BR-049](../../business-rules.md#br-049-n4-postal-code-split-into-zip-and-extension)).

## Context
- Namespace: `SAIF.Common.Files.Edi.Segments`
- Assembly/package: `SAIF.Framework.Common.Files`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| SegmentId | `string SegmentId { get; }` | Returns the literal X12 segment identifier `"N4"`. |
| CityName | `string CityName { get; set; }` | The party's city name (N401), element 1. |
| StateCode | `string StateCode { get; set; }` | The party's state or province code (N402), element 2. |
| ZipCode | `string ZipCode { get; set; }` | The first five characters of the postal code (N403 positions 1-5) ([BR-049](../../business-rules.md#br-049-n4-postal-code-split-into-zip-and-extension)). |
| ZipCodeExtension | `string ZipCodeExtension { get; set; }` | The remaining characters of the postal code beyond the first five (N403 positions 6-9), set only when the original value exceeds five characters ([BR-049](../../business-rules.md#br-049-n4-postal-code-split-into-zip-and-extension)). |
| Build | `IEdiSegment Build()` | Creates a `SegmentBuilder("N4")` and adds `CityName`, `StateCode`, and the concatenation `ZipCode + ZipCodeExtension` at elements 1-3, returning the built segment ([BR-049](../../business-rules.md#br-049-n4-postal-code-split-into-zip-and-extension)). |
| Fill | `void Fill(IEdiSegment segment)` | Reads elements 1-2 into `CityName`/`StateCode`; for element 3, if the value's length exceeds 5 splits it into `ZipCode` (first 5 chars) and `ZipCodeExtension` (remainder), otherwise assigns the whole value to `ZipCode` ([BR-049](../../business-rules.md#br-049-n4-postal-code-split-into-zip-and-extension)). |
| Parse | `static N4Segment Parse(IEdiSegment segment)` | Instantiates a new `N4Segment`, calls `Fill(segment)` on it, and returns it. |

## Sources
- Common\SAIF.Common.Files\Edi\Segments\N4Segment.cs
