Presentation is loading. Please wait.

Presentation is loading. Please wait.

1.10 Strings academy.zariba.com 1. Lecture Content 1.What is a string? 2.Creating and Using strings 3.Manipulating Strings 4.Other String Operations 5.Building.

Similar presentations


Presentation on theme: "1.10 Strings academy.zariba.com 1. Lecture Content 1.What is a string? 2.Creating and Using strings 3.Manipulating Strings 4.Other String Operations 5.Building."— Presentation transcript:

1 1.10 Strings academy.zariba.com 1

2 Lecture Content 1.What is a string? 2.Creating and Using strings 3.Manipulating Strings 4.Other String Operations 5.Building strings 6.Formatting Strings 2

3 1. What is a string? 3 Strings are sequences of characters. Each character is a Unicode symbol. String objects in C# are immutable(read-only). Strings are like arrays of character. Have a fixed length. Characters can be accessed by index

4 2. Creating and Using Strings 4

5 3. Manipulating strings 5 Comparing, concatenating, searching, splitting etc.

6 4. Other String Operations 6 Replacing and deleting substrings, changing character casing, trimming.

7 5. Building Strings 7 Using the “+” operator to build strings is slow. This is why there is StringBuilder.

8 6. Formatting String 8

9 Homework 9 1. Write a program that reads a string, reverses it and prints the result at the console. Do NOT use any built in methods! 2. Write a program to check if in a given expression the brackets are put correctly. Correct:((x-y)/(10-z)). Incorrect: )(x*y)-1). 3. Write a program that finds how many times a substring is contained in a given text (perform case insensitive search). 4. Write a program that reads from the console a string of maximum 20 characters. If the length of the string is less than 20, the rest of the characters should be filled with '*'. Print the result string into the console. 5. Write a program that extracts from a given text all sentences containing given word.

10 Homework 10 6.Write a program that reverses the words in given sentence. 7.Write a program that extracts from a given text all sentences containing given word. 8.Write a program that extracts from a given text all palindromes, e.g. “level", “stats", “radar". 9.Write a program that reads a string from the console and prints all different letters in the string along with information how many times each letter is found. 10.Write a program that reads a string from the console and lists all different words in the string along with information how many times each word is found. 11.Write a program that reads a string from the console and replaces all series of consecutive identical letters with a single one. Example: “zzzzzaaaarrrriiiiiiiibbbbbbbaaaaa"  “zariba".

11 11 References

12 12 Zariba Academy Questions


Download ppt "1.10 Strings academy.zariba.com 1. Lecture Content 1.What is a string? 2.Creating and Using strings 3.Manipulating Strings 4.Other String Operations 5.Building."

Similar presentations


Ads by Google