Write a C# Sharp program to get the index number of all lower case letters in a given string
- برمجة سي شارب
- برمجة
- 2021-05-15
- MarwaMohammed
الأجوبة
using System;
using System.Linq;
using System.Collections.Generic;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
string text;
text = "Python";
Console.WriteLine("Orginal string: "+text);
int[] result = test(text);
Console.WriteLine("\nIndices of all lower case letters of the said string:");
foreach (var item in result)
{
Console.Write(item.ToString()+" ");
}
text = "JavaScript";
Console.WriteLine("\nOrginal string: " + text);
result = test(text);
Console.WriteLine("\nIndices of all lower case letters of the said string:");
foreach (var item in result)
{
Console.Write(item.ToString() + " ");
}
}
public static int[] test(string str)
{
return str.Select((x, i) => i).Where(i => char.IsLower(str[i])).ToArray();
}
}
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال