Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _27_ManipulateStrings
- {
- public class Program
- {
- static void Main(string[] args)
- {
- const string phrase = "Luis would love to have free time to release articles weekly. Give me time...";
- var timeIndexOf = phrase.IndexOf("time");
- var lastIndexOf = phrase.LastIndexOf("time");
- var startsWith = phrase.StartsWith("Luis");
- var endsWith = phrase.EndsWith("Luis");
- var substring = phrase.Substring(timeIndexOf, "time".Length);
- Console.WriteLine($"Index using IndexOf: {timeIndexOf}");
- Console.WriteLine($"Index using LastIndexOf: {lastIndexOf}");
- Console.WriteLine($"Does the phrase starts with 'Luis'? {startsWith}");
- Console.WriteLine($"Does the phrase ends with 'Luis'? {endsWith}");
- Console.WriteLine($"Substring from index {timeIndexOf} with length {"time".Length}: {substring}");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement