0
0
C Sharp (C#)programming~30 mins

String searching and extraction in C Sharp (C#) - Mini Project: Build & Apply

Choose your learning style9 modes available
String Searching and Extraction
📖 Scenario: You work in a customer service team. You receive messages from customers that include their order IDs inside the text. You want to find and extract these order IDs to help track their orders quickly.
🎯 Goal: Build a simple C# program that searches a message for an order ID and extracts it.
📋 What You'll Learn
Create a string variable with a customer message containing an order ID.
Create a string variable for the order ID prefix to search for.
Use string searching to find the order ID in the message.
Extract the order ID substring from the message.
Print the extracted order ID.
💡 Why This Matters
🌍 Real World
Customer service teams often need to find order IDs or tracking numbers inside messages to help customers quickly.
💼 Career
Knowing how to search and extract parts of text is useful for data processing, automation, and building user-friendly tools.
Progress0 / 4 steps
1
Create the customer message string
Create a string variable called message and set it to the exact text: "Hello, my order ID is ORD12345. Can you check the status?"
C Sharp (C#)
Need a hint?

Use double quotes to create the string and assign it to message.

2
Create the order ID prefix variable
Create a string variable called orderPrefix and set it to the exact value "ORD".
C Sharp (C#)
Need a hint?

This prefix helps us find where the order ID starts in the message.

3
Find and extract the order ID
Use IndexOf on message with orderPrefix to find the start index. Then use Substring to extract 8 characters starting from that index and save it in a string variable called orderId.
C Sharp (C#)
Need a hint?

Use IndexOf to find where "ORD" starts, then Substring to get the full order ID which has 8 characters.

4
Print the extracted order ID
Write a Console.WriteLine statement to print the orderId variable.
C Sharp (C#)
Need a hint?

This will show the extracted order ID on the screen.