Menu
Coddy logo textTech

String

Lesson 1 of 14 in Coddy's Strings and Arrays in C# course.

Strings are used for storing text.

A string variable contains a collection of characters surrounded by double quotes:

string name = "Bob";

A string is a special type, it has its own methods (functions) and properties!

The first we will meet is Length, which stores the length of the string,

string name = "Bob";
Console.WriteLine(name.Length);  // Outputs: 3
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

challenge icon

Challenge

Easy

Inside the main funciton:

1. Initialize a variable named car that holds the string "Volvo".

2. Output the length of the variable car, using the property Length.

Try it yourself

using System;

class Program {
    public static void Main(String[] args) {
        // Write code here
    }
}

All lessons in Strings and Arrays in C#