Write a C# Sharp program to check whether a given string is an “isograms” or not. Return True or False
- برمجة سي شارب
- برمجة
- 2021-05-30
- ahmadghneem
الأجوبة
using System;
using System.Linq;
using System.Collections.Generic;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
string str1 = "Python";
Console.WriteLine("Original string: "+ str1);
Console.WriteLine("Check the said string is an 'isograms' or not! " + test(str1));
str1 = "JavaScript";
Console.WriteLine("\nOriginal string: " + str1);
Console.WriteLine("Check the said string is an 'isograms' or not! " + test(str1));
str1 = "PHP";
Console.WriteLine("\nOriginal string: " + str1);
Console.WriteLine("Check the said string is an 'isograms' or not! " + test(str1));
str1 = "C#";
Console.WriteLine("\nOriginal string: " + str1);
Console.WriteLine("Check the said string is an 'isograms' or not! " + test(str1));
}
public static bool test(string str1)
{
int str_len = str1.Length;
return str1.ToLower().Distinct().Count() == str_len;
}
}
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال