# Strings

Having seen dynamic types in action (via dynamic arrays), it is time that we look at the type that has been absent from our discussion of the Solidity programming language: strings. Like most other programming languages, Solidity allows us to write literal text via strings, which have no size restriction.

As with most programming languages, strings in Solidity are an array of characters (represented by a byte); below is the syntax to declaring a string:

```solidity
string M stringName;
```

where `M` is the location of the string; below are the following locations where a string can be defined:

* `memory`: within the body of a function and as a function parameter
* `calldata`: as a function parameter

Below is a code snippet which uses strings extensively:

```solidity
contract StringExample {

    string name = "John";
    
    function getName() public view returns(string memory) {
        return name;
    }
    
    function setName(string calldata _name) public {
        name = _name;
    }

}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cs4998.cornellblockchain.org/introduction/hello-world-pt.-2/dynamic-arrays-and-strings/strings.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
