class Program
{
static void Main(string[] args)
{
int i;
String strMyText = "My Name Is Jithil";
string[] arr = strMyText.Split(' ');
foreach(string str in arr)
{
int iFirstIndex = str.IndexOf(str[0]);
int iLastIndex = str.LastIndexOf(str[str.Length - 1]);
string temp = "";
for(i = 0; i < str.Length; i++)
{
if(str.Length > 2)
if(i != iFirstIndex && i != iLastIndex) temp += "*";
else temp += str[i];
else temp += str[i];
}
Console.Write(temp + " ");
}
Console.ReadLine();
}
}Output:
My N**e Is J****l
My N**e Is J****l
