SlideShare uma empresa Scribd logo
1 de 12
STRINGS

Examining System.String
Building Strings
StringBuilder Class
Format Strings
System.String
 A string is a sequential collection of Unicode characters
  that is used to represent text.
 A String object is a sequential collection of
  System.Char objects that represent a string.
 The value of the String object is the content of the
  sequential collection, and that value is immutable.
 A String object is called immutable (read-only) because
  its value cannot be modified once it has been created.
Some Methods in System.String
Name              Description


Clone             Returns a reference to this instance of String.

                  Compares two specified String objects and returns
Compare(String,
                  an integer that indicates their relative position in the
String)
                  sort order.
                  Creates the string representation of a specified
Concat(Object)
                  object.
                  Creates a new instance of String with the same
Copy
                  value as a specified String.
                  Returns a value indicating whether the specified
Contains
                  String object occurs within this string.
                  Determines whether this instance and a specified
Equals(Object)    object, which must also be a String object, have the
                  same value.
                  Replaces the format item in a specified string with
Format(String,
Building Strings
 String is an extremely powerful class that implements a
  large number of very useful methods.
 However, the String class has a short coming that
  makes it very inefficient for making repeated
  modifications to given string.
 For example, when you write fallowing code, the
  compiler actually creates a new string object to hold the
  new sequence of characters, and that new object is
  assigned to b. The string "h" is then eligible for garbage
  collection.
  Example:
      string b = "h";
      b += "ello";
StringBuilder Class
 Represents a mutable string of characters. This class
  cannot be inherited.
 Namespace is System.Test
 This class represents a string-like object whose value is
  a mutable sequence of characters.
 The value is said to be mutable because it can be
  modified once it has been created by appending,
  removing, replacing, or inserting characters.
   For Example:
     StringBuilder text=new StringBuilder (“….String …”,size);//size is an
      integer
     Text.AppendForamt(“New String….”);
     This code sets an initial capacity of size for StringBuilder
StringBuilder Members
Name             Description

Append()         Appends a string to the current string.

AppendFormat()   Appends a string that has been worked out from a format
                 specifier
Insert()         Inserts a sub string into the current string

Remove()         Removes characters from the current string.

Replace()        Replaces all occurrences of a character with another
                 character or a substring with another substring in the
                 current string.
ToString()       Returns the current string cast to a System.String object.
Format Strings
 Standard numeric format strings are used to format
  common numeric types.
 A standard numeric format string takes the form Axx,
  where A is an alphabetic character called the format
  specifier, and xx is an optional integer called the
  precision specifier.
 The precision specifier ranges from 0 to 99 and affects
  the number of digits in the result.
 Any numeric format string that contains more than one
  alphabetic character, including white space, is
  interpreted as a custom numeric format string.
Format Strings
SPECIFIE APPLIES TO      MEANING               EXAMPLE
R
C        Numeric types   Locale-specific       $4834.50(US)
                         monetary value        £4834.50(UK)
D        Integer types   General integer       4834
         only
E        Numeric types   Scientific notation   4.384E+003

F        Numeric types   Fixed decimal         4834.50

G        Numeric types   General number        4834.5

N        Numeric types   Common locale-        4,384.50(UK/USA)
                         specific format for   4 384,50(continental
                         numbers               Europe
p        Numeric types   Percentage notation   432,000.00%

X        Integer types   Hexadecimal format    1120(if you want to
         only                                  display 0x1120, you will
REGULAR EXPRESSIONS
Regular Expressions
 Regular expressions provide a powerful, flexible, and
  efficient method for processing text.
 The extensive pattern-matching notation of regular
  expressions enables you to quickly parse large amounts
  of text to find specific character patterns; to validate text
  to ensure that it matches a predefined pattern (such as
  an e-mail address); to extract, edit, replace, or delete text
  substrings; and to add the extracted strings to a
  collection in order to generate a report.
 For many applications that deal with strings or that parse
  large blocks of text, regular expressions are an
  indispensable tool.
Regular Expressions
 Regular expressions are part of those small technology
  areas that are incredibly useful in a wide range of
  programs, yet rarely used among developers.
 You can think regular expressions as a mini-
  programming language with one specific scope: to locate
  substrings within a large string expression.
How Regular Expressions Work
 The centerpiece of text processing with regular
  expressions is the regular expression engine, which is
  represented by the
  System.Text.RegularExpressions.Regex object in the
  .NET Framework.
 At a minimum, processing text using regular expressions
  requires that the regular expression engine be provided
  with the following two items of information:
   The regular expression pattern to identify in the text.
   The text to parse for the regular expression pattern.

Mais conteúdo relacionado

Mais procurados (20)

Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
 
Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
2CPP14 - Abstraction
2CPP14 - Abstraction2CPP14 - Abstraction
2CPP14 - Abstraction
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 
Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#
 
Inheritance C#
Inheritance C#Inheritance C#
Inheritance C#
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVA
 
Array in c#
Array in c#Array in c#
Array in c#
 
Collections in-csharp
Collections in-csharpCollections in-csharp
Collections in-csharp
 
Literals,variables,datatype in C#
Literals,variables,datatype in C#Literals,variables,datatype in C#
Literals,variables,datatype in C#
 
Methods in C#
Methods in C#Methods in C#
Methods in C#
 
Structure in c#
Structure in c#Structure in c#
Structure in c#
 
Loops PHP 04
Loops PHP 04Loops PHP 04
Loops PHP 04
 
Learn C# Programming - Data Types & Type Conversion
Learn C# Programming - Data Types & Type ConversionLearn C# Programming - Data Types & Type Conversion
Learn C# Programming - Data Types & Type Conversion
 
Java Streams
Java StreamsJava Streams
Java Streams
 
Interface in java
Interface in javaInterface in java
Interface in java
 

Destaque

Php String And Regular Expressions
Php String  And Regular ExpressionsPhp String  And Regular Expressions
Php String And Regular Expressionsmussawir20
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#Doncho Minkov
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods pptkamal kotecha
 
C# Tutorial
C# Tutorial C# Tutorial
C# Tutorial Jm Ramos
 

Destaque (7)

Strings v.1.1
Strings v.1.1Strings v.1.1
Strings v.1.1
 
Php String And Regular Expressions
Php String  And Regular ExpressionsPhp String  And Regular Expressions
Php String And Regular Expressions
 
Servlets
ServletsServlets
Servlets
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
 
C# Tutorial
C# Tutorial C# Tutorial
C# Tutorial
 

Semelhante a Explore System.String and Regular Expressions

stringstringbuilderstringbuffer-190830060142.pptx
stringstringbuilderstringbuffer-190830060142.pptxstringstringbuilderstringbuffer-190830060142.pptx
stringstringbuilderstringbuffer-190830060142.pptxssuser99ca78
 
Strings Arrays
Strings ArraysStrings Arrays
Strings Arraysphanleson
 
13string in c#
13string in c#13string in c#
13string in c#Sireesh K
 
ppt notes python language operators and data
ppt notes python language operators and datappt notes python language operators and data
ppt notes python language operators and dataSukhpreetSingh519414
 
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
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and StringsEduardo Bergavera
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSowmyaJyothi3
 
Module 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdfModule 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdfMegMeg17
 
Csharp4 strings and_regular_expressions
Csharp4 strings and_regular_expressionsCsharp4 strings and_regular_expressions
Csharp4 strings and_regular_expressionsAbed Bukhari
 
Java: Regular Expression
Java: Regular ExpressionJava: Regular Expression
Java: Regular ExpressionMasudul Haque
 

Semelhante a Explore System.String and Regular Expressions (20)

stringstringbuilderstringbuffer-190830060142.pptx
stringstringbuilderstringbuffer-190830060142.pptxstringstringbuilderstringbuffer-190830060142.pptx
stringstringbuilderstringbuffer-190830060142.pptx
 
String, string builder, string buffer
String, string builder, string bufferString, string builder, string buffer
String, string builder, string buffer
 
Strings Arrays
Strings ArraysStrings Arrays
Strings Arrays
 
C# chap 10
C# chap 10C# chap 10
C# chap 10
 
Chapter - 2.pptx
Chapter - 2.pptxChapter - 2.pptx
Chapter - 2.pptx
 
13string in c#
13string in c#13string in c#
13string in c#
 
Adv. python regular expression by Rj
Adv. python regular expression by RjAdv. python regular expression by Rj
Adv. python regular expression by Rj
 
Computer programming 2 Lesson 12
Computer programming 2  Lesson 12Computer programming 2  Lesson 12
Computer programming 2 Lesson 12
 
package
packagepackage
package
 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
 
3rd june
3rd june3rd june
3rd june
 
2.regular expressions
2.regular expressions2.regular expressions
2.regular expressions
 
Generics collections
Generics collectionsGenerics collections
Generics collections
 
ppt notes python language operators and data
ppt notes python language operators and datappt notes python language operators and data
ppt notes python language operators and data
 
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...
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and Strings
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
 
Module 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdfModule 6 - String Manipulation.pdf
Module 6 - String Manipulation.pdf
 
Csharp4 strings and_regular_expressions
Csharp4 strings and_regular_expressionsCsharp4 strings and_regular_expressions
Csharp4 strings and_regular_expressions
 
Java: Regular Expression
Java: Regular ExpressionJava: Regular Expression
Java: Regular Expression
 

Mais de Raghuveer Guthikonda (8)

C# Delegates
C# DelegatesC# Delegates
C# Delegates
 
Operators & Casts
Operators & CastsOperators & Casts
Operators & Casts
 
Arrays C#
Arrays C#Arrays C#
Arrays C#
 
Generics C#
Generics C#Generics C#
Generics C#
 
Objects and Types C#
Objects and Types C#Objects and Types C#
Objects and Types C#
 
Introduction to C#
Introduction to C#Introduction to C#
Introduction to C#
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
 
Regex in C#
Regex in C#Regex in C#
Regex in C#
 

Último

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Último (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Explore System.String and Regular Expressions

  • 2. System.String  A string is a sequential collection of Unicode characters that is used to represent text.  A String object is a sequential collection of System.Char objects that represent a string.  The value of the String object is the content of the sequential collection, and that value is immutable.  A String object is called immutable (read-only) because its value cannot be modified once it has been created.
  • 3. Some Methods in System.String Name Description Clone Returns a reference to this instance of String. Compares two specified String objects and returns Compare(String, an integer that indicates their relative position in the String) sort order. Creates the string representation of a specified Concat(Object) object. Creates a new instance of String with the same Copy value as a specified String. Returns a value indicating whether the specified Contains String object occurs within this string. Determines whether this instance and a specified Equals(Object) object, which must also be a String object, have the same value. Replaces the format item in a specified string with Format(String,
  • 4. Building Strings  String is an extremely powerful class that implements a large number of very useful methods.  However, the String class has a short coming that makes it very inefficient for making repeated modifications to given string.  For example, when you write fallowing code, the compiler actually creates a new string object to hold the new sequence of characters, and that new object is assigned to b. The string "h" is then eligible for garbage collection. Example: string b = "h"; b += "ello";
  • 5. StringBuilder Class  Represents a mutable string of characters. This class cannot be inherited.  Namespace is System.Test  This class represents a string-like object whose value is a mutable sequence of characters.  The value is said to be mutable because it can be modified once it has been created by appending, removing, replacing, or inserting characters.  For Example:  StringBuilder text=new StringBuilder (“….String …”,size);//size is an integer  Text.AppendForamt(“New String….”);  This code sets an initial capacity of size for StringBuilder
  • 6. StringBuilder Members Name Description Append() Appends a string to the current string. AppendFormat() Appends a string that has been worked out from a format specifier Insert() Inserts a sub string into the current string Remove() Removes characters from the current string. Replace() Replaces all occurrences of a character with another character or a substring with another substring in the current string. ToString() Returns the current string cast to a System.String object.
  • 7. Format Strings  Standard numeric format strings are used to format common numeric types.  A standard numeric format string takes the form Axx, where A is an alphabetic character called the format specifier, and xx is an optional integer called the precision specifier.  The precision specifier ranges from 0 to 99 and affects the number of digits in the result.  Any numeric format string that contains more than one alphabetic character, including white space, is interpreted as a custom numeric format string.
  • 8. Format Strings SPECIFIE APPLIES TO MEANING EXAMPLE R C Numeric types Locale-specific $4834.50(US) monetary value £4834.50(UK) D Integer types General integer 4834 only E Numeric types Scientific notation 4.384E+003 F Numeric types Fixed decimal 4834.50 G Numeric types General number 4834.5 N Numeric types Common locale- 4,384.50(UK/USA) specific format for 4 384,50(continental numbers Europe p Numeric types Percentage notation 432,000.00% X Integer types Hexadecimal format 1120(if you want to only display 0x1120, you will
  • 10. Regular Expressions  Regular expressions provide a powerful, flexible, and efficient method for processing text.  The extensive pattern-matching notation of regular expressions enables you to quickly parse large amounts of text to find specific character patterns; to validate text to ensure that it matches a predefined pattern (such as an e-mail address); to extract, edit, replace, or delete text substrings; and to add the extracted strings to a collection in order to generate a report.  For many applications that deal with strings or that parse large blocks of text, regular expressions are an indispensable tool.
  • 11. Regular Expressions  Regular expressions are part of those small technology areas that are incredibly useful in a wide range of programs, yet rarely used among developers.  You can think regular expressions as a mini- programming language with one specific scope: to locate substrings within a large string expression.
  • 12. How Regular Expressions Work  The centerpiece of text processing with regular expressions is the regular expression engine, which is represented by the System.Text.RegularExpressions.Regex object in the .NET Framework.  At a minimum, processing text using regular expressions requires that the regular expression engine be provided with the following two items of information:  The regular expression pattern to identify in the text.  The text to parse for the regular expression pattern.

Notas do Editor

  1. Refer:http://msdn.microsoft.com/en-us/library/system.string.aspx
  2. http://msdn.microsoft.com/en-us/library/dwhawy9k%28v=VS.100%29.aspx