13,006,705 members (57,921 online)
Rate this:
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 20:49pm
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

Rate this:

## Solution 1

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

Cheers,
Edo
Rate this:

## 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 160 Karthik Bangalore 150 RickZeeland 75 Pete O'Hanlon 55 F-ES Sitecore 55
 OriginalGriff 5,240 ppolymorphe 2,627 RickZeeland 2,570 Kornfeld Eliyahu Peter 2,156 Richard Deeming 1,763