13,408,417 members (44,021 online)
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

Posted 2-Feb-13 21:49pm
Updated 5-Jul-17 23:03pm
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.
Santhosh Babu Mahimairaj 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

## Solution 1

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

Cheers,
Edo

## Solution 2

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");

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

Console.WriteLine(str1);
}
}
}
}
v3

Top Experts
Last 24hrsThis month
 OriginalGriff 400 ppolymorphe 220 Richard Deeming 210 ‭011111100010‬ 175 RDBurmon 140
 OriginalGriff 6,140 Maciej Los 3,405 Richard MacCutchan 2,081 CPallini 1,945 F-ES Sitecore 1,445