Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _27_ManipulateStrings
  4. {
  5. public class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. const string phrase = "Luis would love to have free time to release articles weekly. Give me time...";
  10.  
  11. var timeIndexOf = phrase.IndexOf("time");
  12. var lastIndexOf = phrase.LastIndexOf("time");
  13. var startsWith = phrase.StartsWith("Luis");
  14. var endsWith = phrase.EndsWith("Luis");
  15. var substring = phrase.Substring(timeIndexOf, "time".Length);
  16.  
  17. Console.WriteLine($"Index using IndexOf: {timeIndexOf}");
  18. Console.WriteLine($"Index using LastIndexOf: {lastIndexOf}");
  19. Console.WriteLine($"Does the phrase starts with 'Luis'? {startsWith}");
  20. Console.WriteLine($"Does the phrase ends with 'Luis'? {endsWith}");
  21. Console.WriteLine($"Substring from index {timeIndexOf} with length {"time".Length}: {substring}");
  22.  
  23. Console.ReadKey();
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement