SlideShare une entreprise Scribd logo
1  sur  2
Télécharger pour lire hors ligne
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.

Contenu connexe

Tendances

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 Substringsijistjournal
 
Comparative Adjetive
Comparative AdjetiveComparative Adjetive
Comparative AdjetiveSaraMK10
 
Formal language
Formal languageFormal language
Formal languageRajendran
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9Vince Vo
 

Tendances (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
 

En vedette

En vedette (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
 

Similaire à C# chap 10

Module 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdfModule 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdfMegMeg17
 
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 databaseAmrit 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.docxfaithxdunce63732
 
Strings Arrays
Strings ArraysStrings Arrays
Strings Arraysphanleson
 
Python - Regular Expressions
Python - Regular ExpressionsPython - Regular Expressions
Python - Regular ExpressionsMukesh Tekwani
 
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
 
Python regular expressions
Python regular expressionsPython regular expressions
Python regular expressionsKrishna Nanda
 
String Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesString Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesPrabu U
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and StringsEduardo Bergavera
 
Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3Anton Kasyanov
 

Similaire à 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
 

Plus de Shehrevar Davierwala

Plus de 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
 

Dernier

4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Dernier (20)

4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 

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.