---
title: "Lexical Rules"
url: https://docs.zeroc.com/ice/3.8/slice/lexical-rules
language: csharp
docs_index: https://docs.zeroc.com/llms.txt
---

> For an index of every page, see [llms.txt](https://docs.zeroc.com/llms.txt).

# Lexical Rules

Programming language: C#. Other languages: [C++](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/cpp.md), [Java](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/java.md), [JavaScript](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/js.md), [MATLAB](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/matlab.md), [PHP](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/php.md), [Python](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/python.md), [Ruby](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/ruby.md), [Swift](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/swift.md).

## Comments

Slice supports block comments, delimited by `/*` and `*/`, and line comments, which start with `//` and extend to the end of the line:

```slice
/*
 * Block comment.
 */

// Line comment.
```

Slice also supports doc comments, which document the definition that follows them: line comments that start with `///` and block comments that start with `/**`. See [Comment Syntax](https://docs.zeroc.com/ice/3.8/slice/documenting-slice-definitions/comment-syntax.md).

## Keywords

Slice uses a number of [keywords](https://docs.zeroc.com/ice/3.8/slice/slice-keywords.md), which must be spelled in lowercase, such as `class` and `dictionary`. The keywords `Object` and `Value` are the exceptions: they must be capitalized as shown.

## Identifiers

An identifier begins with an ASCII letter, followed by any number of ASCII letters, digits, and underscores. An identifier cannot begin or end with an underscore, or contain two consecutive underscores: `get_account_name` is legal, but `_account`, `account_`, and `get__account` are not. Non-ASCII letters, such as Å, cannot appear in an identifier.

An identifier cannot end with `Helper`, `Holder`, `Prx`, or `Ptr`: the Slice compilers reserve these suffixes.

### Case Sensitivity

Identifiers that differ only in capitalization are the same identifier: you cannot declare both `TimeOfDay` and `TIMEOFDAY` in the same scope. After you declare an identifier, you must refer to it with the same capitalization; otherwise, the compiler rejects the reference.

### Escaped Identifiers

You can use a Slice keyword as an identifier by prefixing it with a backslash:

```slice
struct Value     // Error!
{
    // ...
}

struct \Value    // OK
{
    // ...
}
```

The backslash lets an existing definition keep a name that a later version of Slice makes a keyword. In new definitions, avoid keywords as identifiers. A backslash before an identifier that is not a keyword has no effect.

### Language Mapping

A Slice identifier maps to an identical C# identifier. For example, the Slice identifier `Clock` becomes the C# identifier `Clock`. A single Slice identifier often results in several C# identifiers: for a Slice interface named `Greeter`, the generated C# code uses the identifiers `Greeter`, `GreeterPrx`, `GreeterPrxHelper`, `GreeterDisp_`, `AsyncGreeter`, and `AsyncGreeterDisp_`.

A Slice identifier that is a C# keyword keeps its name in the generated C# code, which then does not compile. Give this identifier a C# name of your choice with the `cs:identifier` metadata directive. For example, `delegate` is a C# keyword but a valid Slice identifier:

```slice
struct Meeting
{
    ["cs:identifier:delegateName"]
    string delegate;
}
```

In the generated C# code, the field `delegate` becomes `delegateName`.

## See Also

- [Slice Keywords](https://docs.zeroc.com/ice/3.8/slice/slice-keywords.md)
- [Comment Syntax](https://docs.zeroc.com/ice/3.8/slice/documenting-slice-definitions/comment-syntax.md)
- [Slice Metadata Directives](https://docs.zeroc.com/ice/3.8/slice/slice-metadata-directives/csharp.md)
