Wednesday, 2 June 2021

First Char Of Each Word ToUpper in C#

 public static string FirstCharOfEachWordToUpper(string textInfo, string seprator)

        {

            var spString = textInfo.Split(" ");

            var s1 = seprator == " " ? "_" : seprator == "_" ? " " : seprator;

            var result = "";

            foreach (var item in spString)

            {

                string firstLetterOfString = item.Substring(0, 1).ToUpper() + item.Substring(1);

                if (item != spString[spString.Length - 1])

                {

                    result += firstLetterOfString + s1;

                }

                else

                {

                    result += firstLetterOfString;

                }

            }

            return result;

        }

C# coding interview Link

 https://ankitsharmablogs.com/csharp-coding-questions-for-technical-interviews/


In this link you will get following  list of interview questions code

Q.1: How to reverse a string?

Q.2: How to find if the given string is a palindrome or not?

Q.3: How to reverse the order of words in a given string?

Q.4: How to reverse each word in a given string?

Q.5: How to count the occurrence of each character in a string?

Q.6: How to remove duplicate characters from a string?

Q.7: How to find all possible substring of a given string?

Q.8: How to perform Left circular rotation of an array?

Q.9: How to perform Right circular rotation of an array?

Q.10: How to find if a positive integer is a prime number or not?

Q.11: How to find the sum of digits of a positive integer?

Q.12: How to find second largest integer in an array using only one loop?

Q.13: How to find third largest integer in an array using only one loop?