# Fragment class

Namespace: [Grasshopper2.Parsing](https://developer.rhino3d.com/api/gh2/namespace/grasshopper2.parsing.md) · Assembly: [Grasshopper2](https://developer.rhino3d.com/api/gh2/assembly/grasshopper2.md)

```cs
public abstract class Fragment
```

A single categorised span of a string. Fragments are created only by [Fragments](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments.md) and are immutable once that collection is built.

**Derived types:** [BracketFragment](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.bracketfragment.md), [CommentFragment](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.commentfragment.md), [LineBreakFragment](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.linebreakfragment.md), [LiteralFragment](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.literalfragment.md), [NumberFragment](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.numberfragment.md), [SymbolFragment](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.symbolfragment.md), [TerminalFragment](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.terminalfragment.md), [WhitespaceFragment](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.whitespacefragment.md), [WordFragment](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.wordfragment.md)

## Properties

- [After](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragment/after.md): Gets the index of the character after this fragment.
- [Defect](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragment/defect.md): Gets a description of what is wrong with this fragment, or null when no problem exists.
- [Kind](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragment/kind.md): Gets the category of this fragment.
- [Length](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragment/length.md): Gets the number of characters covered by this fragment.
- [Next](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragment/next.md): Gets the following fragment. Never null; the [FragmentKind.Tail](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragmentkind.md) marker returns itself.
- [NextMeaningful](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragment/nextmeaningful.md): Gets the following fragment, skipping whitespace and single line comments. Line breaks and multi line comments are boundaries rather than trivia, and are returned rather than skipped.
- [Prev](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragment/prev.md): Gets the preceding fragment. Never null; the [FragmentKind.Head](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragmentkind.md) marker returns itself.
- [PrevMeaningful](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragment/prevmeaningful.md): Gets the preceding fragment, skipping whitespace and single line comments. Line breaks and multi line comments are boundaries rather than trivia, and are returned rather than skipped.
- [Start](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragment/start.md): Gets the index of the first character of this fragment within [Fragments.Source](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragments/source.md). This index is absolute, and remains valid in every view derived from the original collection.
- [Text](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragment/text.md): Gets the characters covered by this fragment.

## Methods

- [IsAdjacentTo](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragment/isadjacentto.md): Gets whether this fragment is directly adjacent to the given one, with no intervening characters. Used to match multi character operators.
- [IsAll](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragment/isall.md): Tests whether this fragment matches all of the provided filter kinds. Note: this fragment may have additional kinds not covered by the filter, if you want an exact match, just compare against [Fragment.Kind](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragment/kind.md).
- [IsAny](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragment/isany.md): Tests whether this fragment is any of the provided filter kinds.
- [ToString](https://developer.rhino3d.com/api/gh2/type/grasshopper2.parsing.fragment/tostring.md): Gets a description of this fragment, for debugging purposes.
