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

# EdiSegment

`EdiSegment` is the untyped in-memory representation of one X12 segment produced by `EdiSegmentParser` ([BR-020](../../business-rules.md#br-020-first-element-is-the-segment-identifier)) and consumed by typed segment `Fill()`/`Parse()` methods elsewhere in the library to project raw segments into strongly-typed segment classes (e.g. `IsaSegment`, `GsSegment`).

## Purpose
- Holds the segment identifier (`SegmentId`, the first element of the segment) and the ordered collection of `IEdiDataElement` children that make up the segment's data elements.
- `GetElement`/`GetChildValue`/`GetCompositeElement` provide positional lookup into the segment's data elements, insulating typed segment classes from manual list indexing.
- `ToString()` re-serializes the segment back to its X12 text form (via `EdiRecordBuilder.BuildSegmentRecord`) with a trailing segment delimiter, supporting round-trip write scenarios.

## Context
- Namespace: `SAIF.Common.Files.Edi`
- Assembly/package: `SAIF.Framework.Common.Files`
- Base class: `EdiElement`
- Implements: `IEdiSegment`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| SegmentId | `public string SegmentId { get; set; }` | The two-or-three character X12 segment tag (e.g. `"ISA"`, `"GS"`, `"ST"`) that identifies the segment's type; sourced from the segment's first element ([BR-020](../../business-rules.md#br-020-first-element-is-the-segment-identifier)). |
| DataElements | `public IEnumerable<IEdiDataElement> DataElements { get; set; }` | The ordered collection of simple or composite data elements that make up this segment, excluding the segment identifier itself. |
| GetElement | `public IEdiDataElement GetElement(int index)` | Returns the data element at the given ordinal `index`, or `null` if no element occupies that position. |
| GetCompositeElement | `public IEdiCompositeDataElement GetCompositeElement(int index)` | Returns the element at `index` as a composite data element; if the element is not already a composite, re-parses its raw value into one via `EdiCompositeDataElementParser`. |
| GetChildValue | `public string GetChildValue(int index)` | Returns the raw text `Value` of the element at `index`, or `string.Empty` if no element occupies that position. |
| Index | `public int Index { get; set; }` | The segment's ordinal position within its parent `EdiFile`'s flat `Segments` list. |
| Value | `public string Value { get; set; }` | The raw text value of the segment as a whole element (set/used when the segment is treated generically as an `IEdiElement`). |
| Type | `public override ElementType Type { get; }` | Always returns `ElementType.Segment`, identifying this instance as a segment rather than a data element. |
| ToString | `public override string ToString()` | Serializes the segment's data elements back into X12 text (via `EdiRecordBuilder.BuildSegmentRecord`) and appends the segment delimiter (`~`). |

## Inherited public members

Members in this section are inherited from `EdiElement` in `SAIF.Framework.Common.Files`. They are available on this type through inheritance, though `Index`, `Value`, and `Type` are overridden/re-declared above and documented there with their `EdiSegment`-specific behavior.

| Member | Signature | Purpose | Origin |
| --- | --- | --- | --- |
| Index | `public int Index { get; set; }` | The element's ordinal position within its parent. | `SAIF.Framework.Common.Files` — `EdiElement` |
| Value | `public string Value { get; set; }` | The raw text value of this element. | `SAIF.Framework.Common.Files` — `EdiElement` |
| Type | `public abstract ElementType Type { get; }` | Identifies the concrete element kind. | `SAIF.Framework.Common.Files` — `EdiElement` |

## Sources
- Common\SAIF.Common.Files\Edi\EdiSegment.cs
- Common\SAIF.Common.Files\Edi\IEdiSegment.cs
