--Below is the input
--Below is the output
--Below is the code snippet
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter a String");
string inputStr = Console.ReadLine();
string strResult = ExtensionMethod.GetString(inputStr);
Console.WriteLine(strResult);
Console.ReadLine();
}
}
public static class ExtensionMethod
{
public static string GetString(this string str)
{
char[] chars = str.ToCharArray();
string outputStr = string.Empty;
for (int i = 0; i <= chars.Length - 1; i++)
{
if (i < 4)
{
outputStr += chars[i].ToString().ToUpper();
}
else
{
outputStr += chars[i];
}
}
return outputStr;
}
}
No comments:
Post a Comment