Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

C# Sharp Exercises: Index number of all lower case letters in a given string

C# Sharp Basic: Exercise-84 with Solution

Write a C# Sharp program to get the index number of all lower case letters in a given string.

Sample Solution:

C# Sharp Code:

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();
        }
    }
}

Sample Output:

Orginal string: Python

Indices of all lower case letters of the said string:
1 2 3 4 5 
Orginal string: JavaScript

Indices of all lower case letters of the said string:
1 2 3 5 6 7 8 9 

Flowchart:

Flowchart: C# Sharp Exercises - Index number of all lower case letters  in a given string.

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

Previous:Write a C# Sharp program to remove all vowels from a given string.
Next: Write a C# Sharp program to find the cumulative sum of an array of number.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.