IanosStefanCristian

3. Check if a String Contains only Identical Characters

Mar 9th, 2021
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace EdabitChallenges
  8. {
  9. class Program
  10. {
  11. public static void Main(string[] args)
  12. {
  13. string phrase = Console.ReadLine();
  14. Console.WriteLine(isIdentical(phrase));
  15. Console.ReadLine();
  16. }
  17. static bool isIdentical(string str)
  18. {
  19. return str.Distinct().Count() == 1; // numara cate secvente de caractere se repeta
  20. }
  21. }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment