SlideShare a Scribd company logo
Chapter 10
Immutable Strings
string objects are immutable, i.e. we cannot modify the characters contained in them. The string is an
alias for the predefined System.String class in the Common Language Runtime (CLR). The build-in
operations produce a modified version of the string rather than modifying the string on which the
method is called.
Compare() – Compares the strings CompareTo() – Compares the current instance
with another instance
ConCat() – Concatenates two or more strings Copy() – Creates a new string by copying another
CopyTo() – Copies a specified number of chars to
an array of Unicode chars
Equals() – Determines if two strings are equal
Join() – Joins an array of strings together PadLeft() – Left-aligns the strings in a field
PadRight() – Right-aligns the strings in a field Remove () – Deletes characters from the string
Substring() – Extracts a suvbstring ToLower() – Returns a lower-case version of
string
ToUpper() - Returns a upper-case version of string Trim() – Removes white space from the string
TrimEnd() – Removes a string of characters from
the end of the string
TrimStart() – Removes a string of characters from
beginning of the string
Mutable Strings
Mutalbe strings that are modifiable can be created using StringBuilder class
Eg. StringBuilder str1 = new StringBuilder(“abc”);
They grow dynamically as more characters are added to them. Mutable strings are also known as
dynamic strings.
StringBuilder Methods are :
- Append() – Appends a string,
AppendFormat() – Appends strings using a specific format
EnsureCapacity()
– Ensures sufficient size,
Insert() – Inserts a string at a specified position,
Remove() Removes the specified characters
Replace () – Replaces all instances of a character with the specified one
StringBuilder Properties :- Capacity – To retrieve or set the number of characters the object can hold,
Length – To retrieve or set the length
MaxCapacity – To retrieve the maximum capacity of the object,
[ ] – To get or set a character at a specified position
Regular Expressions
- Regular expressions provide a powerful tool for searching and manipulating a large text.
- A regular expression may be applied to a text to accomplish tasks such as
a) to locate the substrings and locate them
b) to modify one or more substrings and return
c) to identify substrings that begin with or end with a pattern of characters
d) to find all words that begin with a group of characters and end with some other characters.
e) To find all the occurrences of a substring patterns
- A regular expression also known as a pattern string is a string containing two types of characters
Literals, Metacharacters, Literals are characters that search and match in the text. Metacharacters are
special characters that give commands to the regular expression parser.
Eg of regular Expressions are “bm” – Any word beginning with m, “erb” – Any word ending
with er “BxB” – Any x in middle of word.
“bms*erb” – Any word beginning with m and ending with er “|,” – Any word separated by a
space or comma
Here, b, B, s* are metacharacters and m, er, x, comma are literals.
The namespace System.Text.RegularExpressions support a number of classes that can be used for
searching, matching and modifying a text document. The important classes are Regex, MatchCollection,
Match
Distinguish between String and StringBuilder class
String Class – The string class lies in the
namespace System
StringBuilder Class – the StringBuilder class lies in
the namespace System.Text
Immutable strings i.e. a string whose character
cannot be modified can be created using the
string class
Mutable strings can be created using the StringBuilder
class.
All operations produce a modified version of
string rather than modifying the string on
which the method is called.
All operation modify the original string on which the
method is called. Hence these type of strings are also
known as dynamic strings.

More Related Content

What's hot

Regular languag regular set
Regular languag regular setRegular languag regular set
Regular languag regular set
Dr. ABHISHEK K PANDEY
 
Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
 Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings  Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
ijistjournal
 
Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
Space Efficient Suffix Array Construction using Induced Sorting LMS SubstringsSpace Efficient Suffix Array Construction using Induced Sorting LMS Substrings
Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
ijistjournal
 
Language
LanguageLanguage
Language
Mobeen Mustafa
 
Comparative Adjetive
Comparative AdjetiveComparative Adjetive
Comparative Adjetive
SaraMK10
 
Huffman
HuffmanHuffman
Huffman
keerthi vasan
 
Formal language
Formal languageFormal language
Formal language
Rajendran
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9
Vince Vo
 

What's hot (8)

Regular languag regular set
Regular languag regular setRegular languag regular set
Regular languag regular set
 
Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
 Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings  Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
 
Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
Space Efficient Suffix Array Construction using Induced Sorting LMS SubstringsSpace Efficient Suffix Array Construction using Induced Sorting LMS Substrings
Space Efficient Suffix Array Construction using Induced Sorting LMS Substrings
 
Language
LanguageLanguage
Language
 
Comparative Adjetive
Comparative AdjetiveComparative Adjetive
Comparative Adjetive
 
Huffman
HuffmanHuffman
Huffman
 
Formal language
Formal languageFormal language
Formal language
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9
 

Viewers also liked

การโปรแกรมภาษาซีชาร์ป
การโปรแกรมภาษาซีชาร์ปการโปรแกรมภาษาซีชาร์ป
การโปรแกรมภาษาซีชาร์ป
KruBeeKa
 
C# chap 1
C# chap 1C# chap 1
C# programs
C# programsC# programs
12 exception handling
12 exception handling12 exception handling
12 exception handling
Arriz San Juan
 
Tech talk webtech
Tech talk webtechTech talk webtech
Tech talk webtech
Shehrevar Davierwala
 
Introduction To C#
Introduction To C#Introduction To C#
Introduction To C#
SAMIR BHOGAYTA
 
Programming in c#
Programming in c#Programming in c#
Programming in c#
Shehrevar Davierwala
 
C# Tutorial
C# Tutorial C# Tutorial
C# Tutorial
Jm Ramos
 
C# basics
 C# basics C# basics
C# basics
Dinesh kumar
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
sharqiyem
 

Viewers also liked (10)

การโปรแกรมภาษาซีชาร์ป
การโปรแกรมภาษาซีชาร์ปการโปรแกรมภาษาซีชาร์ป
การโปรแกรมภาษาซีชาร์ป
 
C# chap 1
C# chap 1C# chap 1
C# chap 1
 
C# programs
C# programsC# programs
C# programs
 
12 exception handling
12 exception handling12 exception handling
12 exception handling
 
Tech talk webtech
Tech talk webtechTech talk webtech
Tech talk webtech
 
Introduction To C#
Introduction To C#Introduction To C#
Introduction To C#
 
Programming in c#
Programming in c#Programming in c#
Programming in c#
 
C# Tutorial
C# Tutorial C# Tutorial
C# Tutorial
 
C# basics
 C# basics C# basics
C# basics
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
 

Similar to C# chap 10

C# String
C# StringC# String
Module 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdfModule 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdf
MegMeg17
 
Andrei's Regex Clinic
Andrei's Regex ClinicAndrei's Regex Clinic
Andrei's Regex Clinic
Andrei Zmievski
 
13string in c#
13string in c#13string in c#
13string in c#
Sireesh K
 
11. using regular expressions with oracle database
11. using regular expressions with oracle database11. using regular expressions with oracle database
11. using regular expressions with oracle database
Amrit Kaur
 
CSE 220 Assignment 3 Hints and Tips Some hints for approa.docx
CSE 220 Assignment 3 Hints and Tips  Some hints for approa.docxCSE 220 Assignment 3 Hints and Tips  Some hints for approa.docx
CSE 220 Assignment 3 Hints and Tips Some hints for approa.docx
faithxdunce63732
 
Strings Arrays
Strings ArraysStrings Arrays
Strings Arrays
phanleson
 
Python - Regular Expressions
Python - Regular ExpressionsPython - Regular Expressions
Python - Regular Expressions
Mukesh Tekwani
 
Python strings
Python stringsPython strings
Python strings
Mohammed Sikander
 
What-is-String-in-Java.pptx
What-is-String-in-Java.pptxWhat-is-String-in-Java.pptx
What-is-String-in-Java.pptx
manojsharma469262
 
Adv. python regular expression by Rj
Adv. python regular expression by RjAdv. python regular expression by Rj
Adv. python regular expression by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_06-Dec...
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_06-Dec...FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_06-Dec...
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_06-Dec...
jaychoudhary37
 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
Muthuselvam RS
 
Python regular expressions
Python regular expressionsPython regular expressions
Python regular expressions
Krishna Nanda
 
M C6java7
M C6java7M C6java7
M C6java7
mbruggen
 
String Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesString Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and Interfaces
Prabu U
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and Strings
Eduardo Bergavera
 
Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov
 
Regex lecture
Regex lectureRegex lecture
Regex lecture
Jun Shimizu
 
Strings.ppt
Strings.pptStrings.ppt
Strings.ppt
SanthiyaAK
 

Similar to C# chap 10 (20)

C# String
C# StringC# String
C# String
 
Module 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdfModule 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdf
 
Andrei's Regex Clinic
Andrei's Regex ClinicAndrei's Regex Clinic
Andrei's Regex Clinic
 
13string in c#
13string in c#13string in c#
13string in c#
 
11. using regular expressions with oracle database
11. using regular expressions with oracle database11. using regular expressions with oracle database
11. using regular expressions with oracle database
 
CSE 220 Assignment 3 Hints and Tips Some hints for approa.docx
CSE 220 Assignment 3 Hints and Tips  Some hints for approa.docxCSE 220 Assignment 3 Hints and Tips  Some hints for approa.docx
CSE 220 Assignment 3 Hints and Tips Some hints for approa.docx
 
Strings Arrays
Strings ArraysStrings Arrays
Strings Arrays
 
Python - Regular Expressions
Python - Regular ExpressionsPython - Regular Expressions
Python - Regular Expressions
 
Python strings
Python stringsPython strings
Python strings
 
What-is-String-in-Java.pptx
What-is-String-in-Java.pptxWhat-is-String-in-Java.pptx
What-is-String-in-Java.pptx
 
Adv. python regular expression by Rj
Adv. python regular expression by RjAdv. python regular expression by Rj
Adv. python regular expression by Rj
 
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_06-Dec...
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_06-Dec...FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_06-Dec...
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_06-Dec...
 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
 
Python regular expressions
Python regular expressionsPython regular expressions
Python regular expressions
 
M C6java7
M C6java7M C6java7
M C6java7
 
String Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesString Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and Interfaces
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and Strings
 
Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3
 
Regex lecture
Regex lectureRegex lecture
Regex lecture
 
Strings.ppt
Strings.pptStrings.ppt
Strings.ppt
 

More from Shehrevar Davierwala

Introduction_Swift
Introduction_SwiftIntroduction_Swift
Introduction_Swift
Shehrevar Davierwala
 
PsudoCode.pptx
PsudoCode.pptxPsudoCode.pptx
PsudoCode.pptx
Shehrevar Davierwala
 
Number System.pptx
Number System.pptxNumber System.pptx
Number System.pptx
Shehrevar Davierwala
 
Java Script (Module 1).pptx
Java Script (Module 1).pptxJava Script (Module 1).pptx
Java Script (Module 1).pptx
Shehrevar Davierwala
 
Website in Clicks Day 2
Website in Clicks Day 2Website in Clicks Day 2
Website in Clicks Day 2
Shehrevar Davierwala
 
Develop Website in Clicks
Develop Website in ClicksDevelop Website in Clicks
Develop Website in Clicks
Shehrevar Davierwala
 
Build Virtual Assistant Using AI
Build Virtual Assistant Using AI Build Virtual Assistant Using AI
Build Virtual Assistant Using AI
Shehrevar Davierwala
 
Build brand reputation using facebook
Build brand reputation using facebookBuild brand reputation using facebook
Build brand reputation using facebook
Shehrevar Davierwala
 
Digital Marketing Session 2
Digital Marketing Session 2Digital Marketing Session 2
Digital Marketing Session 2
Shehrevar Davierwala
 
Learn Digital Marketing : 0 to Hero Day 1
Learn Digital Marketing :  0 to Hero Day 1 Learn Digital Marketing :  0 to Hero Day 1
Learn Digital Marketing : 0 to Hero Day 1
Shehrevar Davierwala
 
Standard template
Standard templateStandard template
Standard template
Shehrevar Davierwala
 
Digital Marketing for Sustainable Business - Afghan Perspective
Digital Marketing for Sustainable Business - Afghan Perspective  Digital Marketing for Sustainable Business - Afghan Perspective
Digital Marketing for Sustainable Business - Afghan Perspective
Shehrevar Davierwala
 
Developing stunning website in clicks - 2
Developing stunning website in clicks - 2Developing stunning website in clicks - 2
Developing stunning website in clicks - 2
Shehrevar Davierwala
 
Developing stunning website in clicks
Developing stunning website in clicksDeveloping stunning website in clicks
Developing stunning website in clicks
Shehrevar Davierwala
 
Google forms for data analysis
Google forms for data analysisGoogle forms for data analysis
Google forms for data analysis
Shehrevar Davierwala
 
Webdesign session1
Webdesign session1Webdesign session1
Webdesign session1
Shehrevar Davierwala
 
Tech talk php_cms
Tech talk php_cmsTech talk php_cms
Tech talk php_cms
Shehrevar Davierwala
 
Ph pbasics
Ph pbasicsPh pbasics
Php mysql
Php mysqlPhp mysql
Java operators
Java operatorsJava operators
Java operators
Shehrevar Davierwala
 

More from Shehrevar Davierwala (20)

Introduction_Swift
Introduction_SwiftIntroduction_Swift
Introduction_Swift
 
PsudoCode.pptx
PsudoCode.pptxPsudoCode.pptx
PsudoCode.pptx
 
Number System.pptx
Number System.pptxNumber System.pptx
Number System.pptx
 
Java Script (Module 1).pptx
Java Script (Module 1).pptxJava Script (Module 1).pptx
Java Script (Module 1).pptx
 
Website in Clicks Day 2
Website in Clicks Day 2Website in Clicks Day 2
Website in Clicks Day 2
 
Develop Website in Clicks
Develop Website in ClicksDevelop Website in Clicks
Develop Website in Clicks
 
Build Virtual Assistant Using AI
Build Virtual Assistant Using AI Build Virtual Assistant Using AI
Build Virtual Assistant Using AI
 
Build brand reputation using facebook
Build brand reputation using facebookBuild brand reputation using facebook
Build brand reputation using facebook
 
Digital Marketing Session 2
Digital Marketing Session 2Digital Marketing Session 2
Digital Marketing Session 2
 
Learn Digital Marketing : 0 to Hero Day 1
Learn Digital Marketing :  0 to Hero Day 1 Learn Digital Marketing :  0 to Hero Day 1
Learn Digital Marketing : 0 to Hero Day 1
 
Standard template
Standard templateStandard template
Standard template
 
Digital Marketing for Sustainable Business - Afghan Perspective
Digital Marketing for Sustainable Business - Afghan Perspective  Digital Marketing for Sustainable Business - Afghan Perspective
Digital Marketing for Sustainable Business - Afghan Perspective
 
Developing stunning website in clicks - 2
Developing stunning website in clicks - 2Developing stunning website in clicks - 2
Developing stunning website in clicks - 2
 
Developing stunning website in clicks
Developing stunning website in clicksDeveloping stunning website in clicks
Developing stunning website in clicks
 
Google forms for data analysis
Google forms for data analysisGoogle forms for data analysis
Google forms for data analysis
 
Webdesign session1
Webdesign session1Webdesign session1
Webdesign session1
 
Tech talk php_cms
Tech talk php_cmsTech talk php_cms
Tech talk php_cms
 
Ph pbasics
Ph pbasicsPh pbasics
Ph pbasics
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
Java operators
Java operatorsJava operators
Java operators
 

Recently uploaded

BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 

Recently uploaded (20)

BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 

C# chap 10

  • 1. Chapter 10 Immutable Strings string objects are immutable, i.e. we cannot modify the characters contained in them. The string is an alias for the predefined System.String class in the Common Language Runtime (CLR). The build-in operations produce a modified version of the string rather than modifying the string on which the method is called. Compare() – Compares the strings CompareTo() – Compares the current instance with another instance ConCat() – Concatenates two or more strings Copy() – Creates a new string by copying another CopyTo() – Copies a specified number of chars to an array of Unicode chars Equals() – Determines if two strings are equal Join() – Joins an array of strings together PadLeft() – Left-aligns the strings in a field PadRight() – Right-aligns the strings in a field Remove () – Deletes characters from the string Substring() – Extracts a suvbstring ToLower() – Returns a lower-case version of string ToUpper() - Returns a upper-case version of string Trim() – Removes white space from the string TrimEnd() – Removes a string of characters from the end of the string TrimStart() – Removes a string of characters from beginning of the string Mutable Strings Mutalbe strings that are modifiable can be created using StringBuilder class Eg. StringBuilder str1 = new StringBuilder(“abc”); They grow dynamically as more characters are added to them. Mutable strings are also known as dynamic strings. StringBuilder Methods are : - Append() – Appends a string, AppendFormat() – Appends strings using a specific format EnsureCapacity() – Ensures sufficient size, Insert() – Inserts a string at a specified position, Remove() Removes the specified characters Replace () – Replaces all instances of a character with the specified one
  • 2. StringBuilder Properties :- Capacity – To retrieve or set the number of characters the object can hold, Length – To retrieve or set the length MaxCapacity – To retrieve the maximum capacity of the object, [ ] – To get or set a character at a specified position Regular Expressions - Regular expressions provide a powerful tool for searching and manipulating a large text. - A regular expression may be applied to a text to accomplish tasks such as a) to locate the substrings and locate them b) to modify one or more substrings and return c) to identify substrings that begin with or end with a pattern of characters d) to find all words that begin with a group of characters and end with some other characters. e) To find all the occurrences of a substring patterns - A regular expression also known as a pattern string is a string containing two types of characters Literals, Metacharacters, Literals are characters that search and match in the text. Metacharacters are special characters that give commands to the regular expression parser. Eg of regular Expressions are “bm” – Any word beginning with m, “erb” – Any word ending with er “BxB” – Any x in middle of word. “bms*erb” – Any word beginning with m and ending with er “|,” – Any word separated by a space or comma Here, b, B, s* are metacharacters and m, er, x, comma are literals. The namespace System.Text.RegularExpressions support a number of classes that can be used for searching, matching and modifying a text document. The important classes are Regex, MatchCollection, Match Distinguish between String and StringBuilder class String Class – The string class lies in the namespace System StringBuilder Class – the StringBuilder class lies in the namespace System.Text Immutable strings i.e. a string whose character cannot be modified can be created using the string class Mutable strings can be created using the StringBuilder class. All operations produce a modified version of string rather than modifying the string on which the method is called. All operation modify the original string on which the method is called. Hence these type of strings are also known as dynamic strings.