1 Lecture Content What is a string Creating and Using strings Manipulating Strings Other String Operations Building strings Formatting Strings 2 1 What is a string 3 Strings are sequences of characters ID: 755595
Download Presentation The PPT/PDF document "1. 10 Strings academy.zariba.com" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
1.10 Strings
academy.zariba.com
1Slide2
Lecture Content
What is a string?Creating and Using strings
Manipulating Strings
Other String Operations
Building strings
Formatting Strings
2Slide3
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 indexSlide4
2. Creating and Using Strings
4Slide5
3. Manipulating strings
5
Comparing, concatenating, searching, splitting etc.Slide6
4. Other String Operations
6
Replacing and deleting substrings, changing character casing, trimming.Slide7
5. Building Strings
7
Using the “+” operator to build strings is slow. This is why there is
StringBuilder
.Slide8
6. Formatting String
8
Slide9
Homework9
Write a program that reads a string, reverses it and prints
the result at the console
. Do NOT use any built in methods!
Write a program to check if in a given expression the brackets are put
correctly. Correct:((x-y)/(10-z)). Incorrect: )(x*y)-1).Write a program that finds how many times a substring is contained in a given text (perform case insensitive search).
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
.
Write a program that extracts from a given text all sentences containing given word
.Slide10
Homework10
Write a program that reverses the words in given
sentence.
Write
a program that extracts from a given text all sentences containing given
word.Write a program that extracts from a given text all palindromes, e.g. “level", “stats", “
radar
".
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.
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.
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
".Slide11
11
ReferencesSlide12
12
Zariba Academy
Questions