Guest User

Untitled

a guest
Mar 24th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CS_Console_string_TrimStart_001
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9.  
  10. // テストデータ
  11. string[] data = {
  12. "ab", // スペースなし
  13. " a b ", // 半角スペース
  14. " a b ", // 全角スペース
  15. "\ta\tb\t", // タブ
  16. };
  17.  
  18. // TrimStart実行
  19. foreach (string text in data)
  20. {
  21. Console.WriteLine("text=[" + text + "] text.TrimStart()=[" + text.TrimStart() + "]");
  22. }
  23.  
  24. Console.WriteLine();
  25.  
  26. // TrimStart実行
  27. foreach (string text in data)
  28. {
  29. Console.WriteLine("text=[" + text + "] text.TrimStart('a')=[" + text.TrimStart('a') + "]");
  30. }
  31.  
  32. Console.WriteLine();
  33.  
  34. // TrimStart実行
  35. foreach (string text in data)
  36. {
  37. Console.WriteLine("text=[" + text + "] text.TrimStart('b')=[" + text.TrimStart('b') + "]");
  38. }
  39.  
  40. Console.WriteLine();
  41.  
  42. // TrimStart実行
  43. foreach (string text in data)
  44. {
  45. Console.WriteLine("text=[" + text + "] text.TrimStart('a', 'b')=[" + text.TrimStart('a', 'b') + "]");
  46. }
  47.  
  48. Console.WriteLine();
  49.  
  50. // TrimStart実行
  51. foreach (string text in data)
  52. {
  53. Console.WriteLine("text=[" + text + "] text.TrimStart('b', 'a')=[" + text.TrimStart('a', 'b') + "]");
  54. }
  55. }
  56. }
  57. }
Add Comment
Please, Sign In to add comment