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: 3This lesson includes a short quiz. Start the lesson to answer it and track your progress.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
Challenge
EasyInside 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
}
}