Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Common methods for the String class . Substring public String Substring(int start todex) Summary: Retrieves a substring from this instance. The substring starts at a

image text in transcribedimage text in transcribed

Common methods for the String class . Substring public String Substring(int start todex) Summary: Retrieves a substring from this instance. The substring starts at a specified character position and continues to the end of the string. Parameter: startIndex: the zero-based starting character position of a substring in this instance Returns: A string that is equivalent to the substring that begins at startIndex in this instance, or System String Empty if startIndex is equal to the length of this instance. . . Example string school = "Georgia Gwinnett College": Console.WriteLine( school Substring(8) ); // Displays "Gwinnett College" Console.Writel.ine schoolSubstring(17) ); // Displays Console.WriteLineschool Substring(21) ); // Displays o G e O r g i a G 0 1 2 3 4 5 6 7 8 w 9 i n e 10 | 11 12 13 t 15 17 1 19 e g e 20 21 22 23 14 16 18 . . Substring public String Substring(int startIndex, int length) Summary: Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length. Parameters: startIndex: The zero-based starting character position of a substring in this instance length: number of characters in the substring Returns: A string that is equivalent to the substring of length Length that begins at startIndex in this instance, or SysteneString Empty if startIndex is equal to the length of this instance and length is zero. Example string school = "Georgia Gwinnett College": Console.WriteLine school Substring(0,5)); // Displays "Georg" Console.Writel.inel school Substring(8,4) ); // Displays Console.WriteLine( school. Substring(12,3) ); // Displays i a G w i n t o 1 1 g e G e o r 0 | 1 2 3 g 4 e 13 t 15 17 e 21 5 6 7 8 9 10 11 12 14 16 18 19 20 22 23 ToLower public String Tel.owere) Summary: Returns a copy of this string converted to lowercase. Returns: The lowercase equivalent of the current string . Example string abbrev = "GGC": string smallAbbrev = abbrev. Tolower(); Console.WriteLine(abbrev ); // Displays Console.WriteLine(smal Abbrev // Displays ToUpper public String ToUppere) Summary: Returns a copy of this string converted to uppercase. Returns: The uppercase equivalent of the current string Example string name = "Natalie" string bigName = name Toupper(); Console.WriteLine(name); Console.WriteLine(bigName); // Displays // Displays EndsWith and StartsWith public bool EndsWith(String value) Summary: Determines whether the end of this string instance matches the specified string Parameter: value: The string to compare to the substring at the end of this instance Returns: true if value matches the end of this instance; otherwise, false public bool StartsWith String value) Summary: Determines whether the beginning of this string instance matches the specified string Parameter: value: The string to compare to the substring at the beginning of this instance Returns: true if value matches the end of this instance; otherwise, false . // Displays Example string city = "Lawrenceville: Console.WriteLineL city EndsWith("le")); Console.WriteLineL city EndsWith("LE")); Console.WriteLinel_cityStartsWith("K")); Console.WriteLine_city StartsWith("Law")); // Displays // Displays // Displays

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions

Question

What is the environment we are trying to create?

Answered: 1 week ago