Sunday 26 July 2015

How to find the last character of the word in Array using C#.net

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StringArray
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strArray = { "GURU","SIVA","KEDAR","RAMU","CHAITHU" };

            ArrayList arr = new ArrayList();
            for (int i = 0; i <strArray.Length  ; i++)
            {
              string strget = strArray[i].ToString();

                int len = strget.Length;

                if (strget[len-1]=='U')
                {
                    arr.Add(strget);
           
                }
           }
            foreach (string  item in arr )
            {
                Console.Write(item);
                Console.WriteLine();
            }
            Console.ReadLine();
     
        }
    }
}



No comments:

Post a Comment