Categories: All Variables and Constants  String manipulation  Builtin functions  Input and output  Arrays  Conditional logic  Repetition / Iteration  Functions / Procedures 

Show:

This resource is designed as a quick reference or revision guide. It has not been endorsed by any exam boards. If you spot any mistakes, please let me know and I'll fix them asap.

Introduction

This website aims to give a quick reference for VB.NET, Python and C# and pseudocode and is aimed primarily at teachers & students working towards a GCSE or A Level in Computer Science

VB.NET, Python and C# are programming languages designed to be understood and followed by computers. Pseudocode is not a programming language: it's written to be understood by humans so that they can turn it into any programming language.

Top Tips:

  • Explore the different categories of skills at the top of this page
    Each skill has example code in Python, C#. You can also enable VB.NET and Pseudocode for OCR GCSE if you'd find that useful.
  • Search for a specific skill
    If you know what you're looking for, use the search bar above the categories list.
Skill
Description
VB.NET
Python
C#
Integer variables
   

Integers are whole numbers

Variables let you store data

Integer variables let you store whole numbers

In this example, a variable called score is declared then set to the integer value of 100

# create a new variable called score score = 100
// create a new variable called score int score = 100;
Real variables
   

Reals are numbers that can contain a decimal place. 

Reals are also known as floats or floating point numbers because they may have a decimal point floating somewhere inside them.

Variables let you store data.

A real variable lets you store a number that can contain a decimal place.

In this example, a variable called height is declared then set to the real value of 6.2

# create a new variable called height height = 6.2
// create a new variable called height double height = 6.2;
Boolean variables
   

Boolean means one of two possible values: usually True or False.

Variables let you store data.

Boolean variables let you store the either value True or False, but nothing else

In this example, a variable called hungry is declared then set to True

# create a new variable called hungry hungry = True
// create a new variable called hungry bool hungry = true;
Character variables
   

Characters are single letters or digits such as '1', 'H' or '?'

Variables let you store data.

Character variables let you store a single letter, number or punctuation mark.

In this example, a variable called letter is declared then set to a full stop.

# create a new variable called letter letter = '.'
// create a new variable called letter char letter= '.';
Integer constants
   

Integers are whole numbers (with no decimal places).

Constants store a value that is set once and then never changes.

Integer constants let you give a whole number a name so you can use it to make your code easier to read or to set options for your code that the user wont be able to change.

In this example, a constant called NUMBER_OF_TRIES is set to the integer value of 10

# Create a new constant called NUMBER_OF_TRIES NUMBER_OF_TRIES = 10
// Create a new constant called NUMBER_OF_TRIES const int NUMBER_OF_TRIES = 10;
Real constants
   

Reals are numbers that can contain a decimal place.

Constants store a value that is set once and then never changes.

Real constants let you give a decimal number a name so you can use it to make your code easier to read or to set options for your code that the user wont be able to change.

In this example, a constant called PI is set to the real value of 3.141

 

# Create a new constant called PI PI = 3.141
// Create a new constant called PI const double PI = 3.141;
Boolean constants
   

Boolean means one of two values (usually either True or False).

Constants store a value that is set once and then never changes.

Boolean constants let you give a boolean value a name so you can use it to make your code easier to read or to set options for your code that the user wont be able to change.

In this example, a constant called CHEAT_MODE is set to the boolean value of True

# Create a new constant called CHEAT_MODE CHEAT_MODE = True
// Create a new constant called CHEAT_MODE const bool CHEAT_MODE = true;
Character constants
   

Characters are single letters or digits such as '1', 'H' or '?'

Constants store a value that is set once and then never changes.

Character constants let you give a character value a name so you can use it to make your code easier to read or to set options for your code that the user wont be able to change.

In this example, a constant called KEY_QUIT is set to the character value of 'Q'

# Create a new constant called KEY_QUIT KEY_QUIT = 'Q'
// Create a new constant called KEY_QUIT const char KEY_QUIT = 'Q';
String variables
    

A string is some text such as "Hello" or "Area 51"

Variables let you store data.

String variables let you store text.

In this example a variable called name is set to the string value of "Bob"

# Create a new variable called name name = "Bob"
// Create a new variable called name string name = "Bob";
String constants
    

A string is some text such as "Hello" or "Area 51"

Constants store a value that is set once and then never changes.

String constants let you give some text data a name so that you can use it to make your code easier to read or set options for your code that the user wont be able to change.

In this example, a constant called ERROR_MESSAGE is set to the string value of "Don't panic!"

# Create a new constant called ERROR_MESSAGE ERROR_MESSAGE = "Don't panic!"
// Create a new constant called ERROR_MESSAGE const string ERROR_MESSAGE = "Don't panic!";
Concatenating strings
   

A string is some text such as "Hello"

Concatenating means joining together or adding / appending on to the end.

Concatenating strings means joining two strings together.

In this example, two strings (first_name and last_name) are concatenated (joined together) and saved in another string variable called full_name with a space in between them.

# create three string variables first_name = "Bob" last_name = "Builder" # concatenate first and last names full_name = first_name + " " + last_name
// create three string variables string firstName = "Bob"; string lastName = "Builder"; // concatenate first and last names fullName = firstName + " " + last_name;
Length of a string
    

A string is some text such as "Hello"

The length of a string means how many characters (including spaces, numbers and punctuation) there are in that string

This example createa a string called name and sets it to "Bob". It counts how many characters are in that string and stores the answer (3) into a variable called l

# create string variable name = "Bob" # count characters and store length l = len(name)
// create string variable string name = "Bob"; // count characters and store length int l = name.Length;
Getting a character from a string
   

A string is some text such as "Hello"

A character is a single letter or digit.

Sometimes it's useful to get the 1st, 2nd or whichever character from a string.

This example gets the first character of a string called name and stores it into a variable called first_letter

name = "Bob" # get the first character from name first_letter = name[0]
string name = "Bob"; // get the first character from name char firstLetter = name[0];
Choose a random number
   

Computers can't think for themselves - they can only follow instructions., so getting them to choose a number that is truely random is not easy. Thankfully, most programming languages have a function that will choose a number for you that appears to be chosen at random.

This example generates a random integer between 0 and 10 and saves it into a variable called r

# do this once, at the start of your code import random ' store a random number between 0 and 10 r = random.randint(0, 10)
// do this once, at the start of your code Random rnd = new Random(); // store a random number between 0 and 10 int r = rnd.Next(0, 10);
Comments
  

Comments don't affect how the code runs. They're there to explain the code so that the programmer (or someone else) can understand what the code does. 

Well written comments describe what a line or section of code does. They make your code easier to maintain / extend / improve / debug in the future.

 

# Comments start with a hash
// Single line comments have double forwardslash /* Multi line comments Are useful for longer descriptions /*
Displaying text
    

Most programs need to output text to the user. 

This example displays the text "Hello" to the screen

# display text print("Hello")
// display text Console.WriteLine("Hello");
Displaying a string variable
   

A string variable lets your program store text that might change as your program runs.

This example creates a string variable called name and displays it to the screen.

# create a variable called name name = "Bob" # display name print(name)
// create a variable called name string name = "Bob"; // display name Console.WriteLine(name);
Displaying an integer variable
   

An integer variable lets your program store a whole number that might change as your program runs.

This example creates an integer variable called score and displays it to the screen.

# create a variable called score score = 10 # convert score to a string then display it print(str(score))
// create a variable called score int score = 10; // convert score to a string then display it Console.WriteLine(score);
Displaying a mixture of text and variables
    

Variables let your program store data of a particular data type.

Integer variables store whole numbers. String variables store text.

Sometimes you need to combine text with integer variables and string variables when you display it to the screen.

This example has a string variable called name (set to "Bob") and an integer variable called score (set to 10). It combines both variables with some text to display the message "Bob has 10 points"

score = 10 name = "Bob" print(name + " has " + str(score) + " points")
int score = 10; string name = "Bob"; Console.WriteLine(name + " has " + score + " points");
Get user input
    

Most programs need to get the user to type in data that controls how the program behaves.

This program asks the user for their name and saves the result into a string variable called name.

# Prompt the user to enter some text name = input("Enter your name")
// Prompt the user to enter some text Console.WriteLine("Enter your name"); string name = Console.ReadLine();
Ask the user to enter a string
   

A string is some text that can contain more than one letter, number, space or punctuation mark. 

This program asks the user their name and saves the result into a string variable called name.

name = input("What is your name?")
Console.WriteLine("Enter your name"); string name = Console.ReadLine();
Ask the user to enter an integer
   

An integer is a whole number.

This program asks the user to type in their age. Whatever the user types in is then saved into an integer variabled called age.

name = int(input("How old are you?"))
Console.WriteLine("How old are you?"); int name = int.Parse(Console.ReadLine());
Write a string to a file
   

A string is some text that can contain more than one letter, number, space or punctuation mark.

This example writes the string "Hello world" to the file "output.txt"

# open the file f = open("output.txt", "w") # write to the file f.write("Hello world") # close the file so it can be read by other programs f.close()
// add this to the top of your file using System.IO; // Open the file using(StreamWriter sw = new StreamWriter("output.txt")) { // write to the file sw.WriteLine("Hello world"); }
Write an integer to a file
   

An integer is a whole number (without any decimal places).

This example writes the numbers 1-10 into a file called numbers.txt

# open the file f = open("numbers.txt", "w") # loop from 1 to 10 for num in range(1, 10): # write number to the file f.write(num) # add blank line to file f.write("\n") # close the file so it can be read by other programs f.close()
// add this to the top of your file using System.IO; // open the file using(StreamWriter sw = new StreamWriter("numbers.txt")) { // loop from 1 to 10 for(int num = 0; num < 10; num++) { // write number to the file sw.WriteLine(num); } }
Write data to a csv file
   

A csv file stands for a Comma-separated-values file. It will open as a spreadsheet (often in Excel) with lots of data organised into rows and columns.

When you open the csv file in a text editor (like notepad), the value for each cell is separated by a comma. Each row is written on a new line.

This example writes the 3 times table to a file called "timestables.csv":

e.g:

1, 3

2, 6

3, 9

4, 12

etc...

# open the file f = open("timestables.csv", "w") # loop from 1 to 10 for num in range(1, 10): # write to the file f.write(num) f.write(",") f.write(num*3) f.write("\n") # close the file so it can be read by other programs f.close()
// add this to the top of your file using System.IO; // open the file using(StreamWriter sw = new StreamWriter("timestables.csv")) { // lop from 1 to 10 for(int num = 1; num < 10; num++){ // write to the file sw.Write(num); sw.Write(","); sw.Write(num*3); sw.Write("\n"); } }
Create array of strings
   

An array let your store more than one piece of data into the same variable as an ordered list.

This example stores three strings into the array called names.

names = ["Percy", "James", "Gordon"]
string[] names = {"Percy", "James", "Gordon"};
Create array of numbers
   

An array lets you store more than one piece of data into the same variable as an ordered list.

This example stores three numbers into the array called ages.

ages = [14, 15, 14]
int[] ages = {14, 15, 14};
Access data in an array
   

An array lets you store more than one piece of data into the same variable as an ordered list.

Data in an array can be accessed using an index. This is a number which defines the position in the list, which starts counting from 0

This example displays the first string in an array called names

names = ["Percy", "James", "Gordon"] print(names[0])
string[] names = {"Percy", "James", "Gordon"}; Console.WriteLine(names[0]);
Create a 2D array
   

If an array is like a list of data, a 2d array is like a grid of data where the data is stored in one variable but organised into rows and columns like a spreadsheet.

This example stores details of 3 different fruit for a supermarket.

It will then display the colour of the first fruit.

The first index will select the row then the second index selects the column

fruit = [["Plumb", "Purple"], ["Apple", "Red"], ["Banana", "Yellow"]] print(fruit[0][1])
string[,] fruit = { {"Plumb", "Purple"}, {"Apple", "Red"}, {"Banana", "Yellow"} }; Console.WriteLine(fruit[0,1]);
IF statement
   

If you want your code to make a decision you'll need an IF statement.

This example asks the user how old they are and checks that they've entered a number bigger than 0

age = int(input("How old are you?")) if age < 0: print("You can't be less than 0 years old!")
Console.WriteLine("How old are you?"); int age = int.Parse(Console.ReadLine()); if(age < 0) { Console.WriteLine("You can't be less than 0 years old!"); }
IF ... ELSE statement
   

If you want your code to choose between two possibilities you'll need an IF ... ELSE statement.

This example asks the user what their name is. If they answer the question it says hello. If they don't answer the question it displays an error message.

name = input("What is your name?") if name == "": print("You have to enter your name") else: print("Hello " + name)
Console.WriteLine("What is your name?"); string name = Console.ReadLine(); if(name == "") { Console.WriteLine("You have to enter your name"); } else { Console.WriteLine("Hello " + name); }
Not equal to
   

You can test if two expressions are the same using the equal to or not equal to operator.

An expression can be a variable or combination of variables & data (e.g. 1 + 1)

An operator is a symbol that means add, subtract or something similar.

This example asks the user to enter a temperature  of a bath (in degrees Celsius) and then follows the following rules:

Equal to 37 degrees: says "Perfect - that's body temperature"

Not equal to 37 degrees: "Not body temperature"

temperature = int(input("What's the temperature of the bath?") if temperature == 37: print("Perfect - that's body temperature") if temperature != 37: print("Not body temperature")
Console.WriteLine("What's the temperature of the bath?"); int temperature = int.Parse(Console.ReadLine()); if(temperature == 37) { Console.WriteLine("Perfect - that's body temperature"); } if(temperature != 37) { Console.WriteLine("Not body temperature"); }
Greater than or less than
   

If you need to compare two expressions you will need the greater than or less than operators.

An expression can be a variable or combination of variables & data (e.g. 1 + 1)

An operator is a symbol that means add, subtract or something similar.

This example asks the user to enter a password and displays how strong that password is based purely on the length:

Less than 5 characters: weak

More than or equal to 8 characters: strong

Otherwise: medium

password = input("Please enter a password") if len(password) >= 8: print("strong") else: if len(password) < 5: print("weak") else: print("medium")
Console.WriteLine("Please enter a password"); string password = Console.ReadLine(); if (password.Length >= 8) { Console.WriteLine("strong"); } else { if(password.Length < 5) { Console.WriteLine("weak"); } else { Console.WriteLine("medium"); } }
While loop
   

A while loop will keep repeating whilst a condition is met (it will stop repeating when the condition is no longer met). 

This is known as a pre-conditioned loop because the program checks if the condition has been met before the code in the loop runs. This means that the minimum number of times the loop will run could be 0.

It is also an example of indefinite iteration because the loop could carry on forever unless the condition is met.

This example program keeps asking the user "Are we nearly there yet" until they say "yes"

nearly_there = "no" while nearly_there != "yes": nearly_there = input("Are we nearly there yet?")
string nearly_there = "no"; while(nearly_there != "yes") { Console.WriteLine("Are we nearly there yet?"); nearly_there = Console.ReadLine(); }
Repeat Until loop
   

A repeat until loop will keep repeating until a condition is met.

This is known as a post-conditioned loop because the program checks if the condition has been met after the code in the loop runs. This means that the loop will always run at least once.

It is also an example of indefinite iteration because the loop could carry on forever if the condition is never met.

This example program keeps asking the user "Are we nearly there yet?" until they say "yes"

# there is no post-conditioned loop in python # but this works in the same way while True: nearly_there = input("Are we nearly there yet?") if nearly_there == "yes": break
string nearly_there; do { Console.WriteLine("Are we nearly there yet?"); nearly_there = Console.ReadLine(); } while (nearly_there != "yes");
Repeat ... times
   

Repeating ... number of times is known as a count controlled loop because you specify exactly how many times the loop will repeat.

Repeat ... times is an example of definite iteration because the number of times the loop repeats is clearly defined.

This example program will repeat the word "Why?" 10 times

for i in range(10): print("Why?")
for(int i = 0; i < 10; i++) { Console.WriteLine("Why?"); }
For loop
   

A for loop is a count-controlled loop which means it your code says exactly how many times the loop should repeat. 

A for loop will use a variable to count between the minimum and maximum value. This variable is called the index, which is why for loops often use the variable i.

A for loop is an example of definite iteration because the number of times the loop repeats is clearly defined.

This example will count from 10 to 20

for i in range(10,21): print(i)
for(int i = 10; i < 21; i++) { Console.WriteLine(i); }
For loop (with step)
   

for loop is a count-controlled loop which means it your code says exactly how many times the loop should repeat. 

A for loop will use a variable to count between the minimum and maximum value. This variable is called the index, which is why for loops often use the variable i.

Rather than increasing the index by 1 each time, you can step up by any amount until you reach the maximum.

This example will count down from 10 to 1 then say "Blast off!" 

for i in range(10,0,-1): print(i) print("Blast off!")
for(int i = 10; i > 0; i--) { Console.WriteLine(i); } Console.WriteLine("Blast off!");
For Each loop
   

A for each loop means the code in the loop will run once for each item in an array.

This means it is a count-controlled loop because the number of times the loop will run is not dependent on a condition being met: you know how many times it will repeat in advance.

A for each loop is an example of definite iteration because the number of times the loop repeats is clearly defined.

This example will display the lyrics for "The wheels on the ... go round and round"  for an array containing the strings "bus", "car" and "tram"

vehicles = ["bus", "car", "tram"] for vehicle in vehicles: print("The wheels on the " + vehicle + " go round and round") print("Round and round, round and round") print("The wheels on the " + vehicle + " go round and round") print("All day long")
string[] vehicles = {"bus", "car", "tram"}; foreach (stringvehicle in vehicles) { Console.WriteLine("The wheels on the " + vehicle + " go round and round"); Console.WriteLine("Round and round, round and round"); Console.WriteLine("The wheels on the " + vehicle + " go round and round"); Console.WriteLine("All day long"); }
Create and use a procedure
   

A procedure is a section of code that has a name that you can re-use to do something useful.

A procedure definition is the code that tells the computer what to do whenever that procedure runs.

The procedure wont actually do anything until you call it.

This example defines a procedure that shows a random word then calls it twice.

import random # define show_random_word procedure def show_random_word(): words = ["wibble", "wobble", "plop"] print(random.choice(words)) # call show_random_words twice show_random_word() show_random_word()
// define showRandomWord procedure void showRandomWord() { Random r = new Random(); string[] words = {"wibble", "wobble", "plop"}; int position = r.Next(words.Length); Console.WriteLine(words[position]); } // call show_random_words twice showRandomWord(); showRandomWord();
Create and use a procedure with parameters
   

A procedure is a section of code that has a name, that you can re-use to do something useful.

Parameters are variables that allow you to send data to the procedure to customise what it does or how it works. 

A procedure definition is the code that tells the computer what to do whenever that procedure runs. The parameters are the variables named in brackets after the procedure name.

The procedure wont actually do anything until you call it.

This example defines a procedure which will display a random number. It has two parameters which allow you to set the minimum and maximum number the random number will be between.  

This procedure is called to show a random number between 10 and 20 and then called again to choose a random number between 50 and 100.

import random # define the procedure def show_random_between(min, max): print(random.randint(min, max)) # call the procedure show_random_between(10, 20) show_random_between(50, 100)
// define the procedure void showRandomBetween(int min, int max) { Random r = new Random(); int number = r.Next(min, max); Console.WriteLine(number); } // call the procedure showRandomBetween(10, 20); showRandomBetween(50, 100);
Create and use a function
   

A function is like a procedure except that it always returns a value.

This return value is calculated when the function is called and can be saved into a variable or used later in the program.

Both functions and procedures are sections of code that have been given a name, which can be re-used to do something useful.

This example defines a function which chooses a random word. This function is called twice with the return value being stored into separate variables.

import random # define choose_random_word function def choose_random_word(): words = ["wibble", "wobble", "plop"] return random.choice(words) # call choose_random_words twice first_word = choose_random_word() second_word = choose_random_word()
// define chooseRandomWord function string chooseRandomWord() { Random r = new Random(); string[] words = {"wibble", "wobble", "plop"}; int position = r.Next(words.Length); return words[position]; } // call choose_random_words twice firstWord = chooseRandomWord() secondWord = chooseRandomWord()
Create and use a function with parameters
   

A function is like a procedure except that it always returns a value.

Parameters are variables that allow you to send data to the function to customise what it does or how it works. 

The parameters are the variables named in brackets after the function name.

This return value is calculated when the function is called and can be saved into a variable or used later in the program.

Both functions and procedures are sections of code that have been given a name, which can be re-used to do something useful.

This example defines a function which will generate and return a random number. It has two parameters which allow you to set the minimum and maximum number the random number will be between.  

This function is called to choose a random number between 10 and 20 and then called again to choose a random number between 50 and 100. Both numbers are returned and saved into separate variables.

import random # define the function def choose_random_between(min, max): print(random.randint(min, max)) # call the function first_number = choose_random_between(10, 20) second_number = choose_random_between(50, 100)
// define the function int showRandomBetween(int min, int max) { Random r = new Random(); int number = r.Next(min, max); return number; } // call the function int firstNumber = showRandomBetween(10, 20); int secondNumber = showRandomBetween(50, 100);
Casting (converting) to a string
     

Often it's useful to convert a number (integer or real data type) to text (string data type) so that it can be processed or sent as an output later in the program.

This example converts the integer number 1000 to a string containing "1000"

# create an integer variable int_number = 1000 # cast the integer to a string str_number = str(int_number)
// create an integer variable int intNumber = 1000; // cast the integer to a string string strNumber = intNumber.toString();
Casting (converting) to an integer
     

Often it's useful to round a decimal number (real data type) to a whole number (integer data type).

It can also be useful to convert a string representation of a number (e.g. one typed in by the user) to an integer

This example converts the string "1000" to the integer 1000

# create a string variable containing an integer str_number = "1000" # cast the string to an integer int_number = int(str_number)
// create a string variable containing an integer string strNumber = "1000"; // cast the string to an integer int intNumber = int.Parse(strNumber);
Casting (converting) to a real
     

Often it's useful to convert a string representation of a number (e.g. one typed in by the user) to a decimal number for use in calculations (real data type)

This example converts the string "1.1234" to the real value 1.1234

# Create a string variable containing a real value str_number = "1.1234" # Cast the string to a real float_number = float(str_number)
// Create a string variable containing a real value strNumber = "1.1234"; // Cast the string to a real floatNumber = double.Parse(strNumber);
Read all data from a text file
   

The easiest way to read data from a file is to get the whole file contents as a string.

This example loads the contents of the file "data.txt" into a string variable called contents

f = open("data.txt") contents = f.read() f.close()
// add this to the top of your file using System.IO; using(StreamReader sr = new StreamReader("data.txt")) { string contents = sr.ReadToEnd(); }
Create a list of strings
   

A list is similar to an array: both allow more than one piece of data to be stored in the same variable.

It's not possible to add or remove data to an array after it's been set for the first time but it is possible to add or remove data to a list.

This example creates a list called colours and adds three strings into it before displaying the first item in the list.

colours = [] colours.append("Red") colours.append("Green") colours.append("Blue") print(colours[0])
// using System.Collections.Generic; List<string> colours = new List<string>(); colours.Add("Red"); colours.Add("Green"); colours.Add("Blue"); Console.WriteLine(colours[0]);
Create a list of integers
   

list is similar to an array: both allow more than one piece of data to be stored in the same variable.

It's not possible to add or remove data to an array after it's been set for the first time but it is possible to add or remove data to a list.

This example creates a list called numbers and adds three integer numbers into it before displaying the sum of all the numbers added together.

numbers = [] numbers.append(1) numbers.append(2) numbers.append(3) print(sum(numbers))
// using System.Collections.Generic; // using System.Linq; List<int> numbers = new List<int>(); numbers.Add(1); numbers.Add(2); numbers.Add(3); // Sum requires System.Linq Console.WriteLine(numbers.Sum());
Remove data from a list
   

list is similar to an array: both allow more than one piece of data to be stored in the same variable.

It's not possible to add or remove data to an array after it's been set for the first time but it is possible to add or remove data to a list.

This example creates a list of strings called names. It adds 3 names to the list then removes the first one.

names = ["Alice", "Bob", "Charlie"] names.pop(0)
// using System.Collections.Generic; List<string> names = new List<string> { "Alice", "Bob", "Charlie" }; names.RemoveAt(0);
Splitting a string into an array of strings
    

It can be really useful to split one string into lots of smaller parts whenever you see a particular character.

This example will split the string "red,green,blue" into an array of smaller strings: "red", "green" and "blue"

It will then display the first colour: red

# Create a string storing comma separated values colours = "red,green,blue" # Split the values into an array of strings parts = colours.split(",") # Get the first value in the array print(parts[0])
// Create a string storing comma separated values string colours = "red,green,blue"; // Split the values into an array of strings string[] parts = colours.Split(","); // Get the first value in the array Console.WriteLine(parts[0]);
Getting part of a string (substring)
   

A string is some text. A substring is part of a bigger string. For example, "name" is a substring of "Hello, what's your name?".

This example creates a variable containing the string "What is your name" then displays the substring of the 5th and 6th characters ("is")

 

message = "What is your name?" # Get the 5th and 6th characters print(message[5:7])
string message = "What is your name?"; // Get the 5th and 6th characters Console.WriteLine(message.Substring(5,2));

Loading...