Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
1.70/5 (3 votes)
See more:
Dear All,

In interview i was given a logical task

To print number from 1 to 50 asp.net C#

But it should be in this format

1
TWO
3
4
Five
6
.
.
.
.
.
.
11
1Two
13
14
1Five
till 50


means 2 must be replace with "TWO" and 5 with Five

how to do this

and ha

it must be further modified to accept input from user like lowest number and highest number and same replacement must be done in this series also how to solve this

please help me
Thanks in advance
Posted
Updated 5-Jul-17 22:03pm
Comments
Sandeep Mewara 3-Feb-13 3:09am    
It does not work like this here.

Here is what is expected of enquirers:
1. TRY first what you want to do! You may find that it's not that hard.
2. Formulate what was done by you that looks like an issue/not working.

Try them and tell if you face issues.
Members will be more than happy to help like this.
[no name] 25-Sep-14 6:42am    
dude wt abt 22 25 ?
we need to display TWO TWO or 2TWO
like that 25 also TWO FIVE or 2FIVE

You can use Sring.Replace:
C#
string str = "12345";
str = str.Replace("2", "Two").Replace("5", "Five");
// str is now "1Two34Five";


Cheers,
Edo
 
Share this answer
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int count;
Console.WriteLine("enter range");
count = Convert.ToInt32(Console.ReadLine());

for (int i = 0; i < count; i++)
{
string str = Convert.ToString(i);
string str1 = str.Replace("2", "Two").Replace("5", "Five");

Console.WriteLine(str1);
}
Console.ReadLine();
}
}
}
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900