Char
Part of the Fundamentals section of Coddy's C# journey — lesson 6 of 69.
A char is a single character (For example: 1, 6, %, b, p, ., T, etc.)
To initialize a char value in a variable, enclose it within single quotation marks:
char c1 = 'h';In the above example, a char variable named c1 is initialized.
Challenge
BeginnerStore the char B in a variable named initial.
Cheat sheet
A char is a single character (numbers, letters, symbols, etc.)
To initialize a char variable, enclose the character in single quotation marks:
char c1 = 'h';Try it yourself
using System;
public class Program {
public static void Main(string[] args) {
// Type your code below
char initial = ?
// Don't change the line below
Console.WriteLine("initial = " + initial);
}
}This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
4Operators Part 1
Arithmetic OperatorsModulo OperatorIncrement/DecrementPost Increment/DecrementArithmetic Shortcuts5Operators Part 2
Comparison OperatorsLogical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3