This question already has answers here:
Closed 12 years ago.
Possible Duplicates:
Is there an easy way to create ordinals in C#?
How can I convert an integer into its verbal representation?
Hi All,
How to convert number to arabic word?
I want output like:
1: First
2: Second,
201: Two hundred first etc
I have try some code but it words for 1..21,23...31,33...41,43..49,51... and then after it does not work.
Is there any special logic for converting 2 in arabic?
Please give me some idea for converting number to word.
Thanks,
Naresh
Please check this previous SO Post on how to change numbers into words.
Related
This question already has answers here:
Regular expression for version numbers
(8 answers)
Closed 2 years ago.
I have a required to validate the version numbers using regex. I tried few but not working as expected.
Any idea what regex to use to validate versions like 1.0.10.135 in C#. Every number should grow upto 3 digits in each section.
Update I tried this "[\d]{1,3}.[\d]{1,3}.[\d]{1,3}.[\d]{1,3}" and it accepted "1.0.0.3##", which is not correct.
If you want to go with a regex, I'm surprised you haven't found one that worked. Here's a quick one (it worked the first time I tried it):
(?<major>\d{1,3})\.(?<minor>\d{1,3})\.(?<patch>\d{1,3})(\.(?<build>\d{1,3}))?
It names the parts, and makes the last part optional
This question already has answers here:
How to get all the unique n-long combinations of a set of duplicatable elements?
(5 answers)
Closed 3 years ago.
I am trying to save every combination of AAAAAAAA - ZZZZZZZZ to a text file. So far after having many many errors, I have got almost nowhere. I could post my code if needed, but it doesn't work or get near the wanted outcome.
So I was wondering how to do this in c#. My method at the moment is beyond repair, I will have to start all again in order to fix this.
As the output I would like something along the lines of
AAAAAAAA, AAAAAAAB, AAAAAAAC ... ZZZZZZZX, ZZZZZZZY, ZZZZZZZZ
Thanks in advance for any help.
This is a basic combinatorics question:
You want to write a string of 8 characters.
Each character can be a letter between A-Z (26 options), therefore, there are 26^8 combinations: 26*26*26*...26.
That is 208827064576 combinations.
Each combination is 10 bytes (8 for string, then \r\n), which is a total of 1944.85 GB.
Are you sure you want to write it to a file?
This will take about 1.5-2 Terabytes. That's a huge text file to start with, probably impractical.
Secondly, the way to do this simply is to have 8 nested loops, each running through A to Z, then concatenate the string inside the inner loop, appending to the data store each time.
This question already has answers here:
Find and extract a number from a string
(32 answers)
Closed 7 years ago.
I already tried to determinate the digits in a sentence using 'isDigit', but this gives me a 'bool' output. I need an 'int' output.
What i want to do is, say, i have the sentence "cheese23"; "2" and "3" will be put in their own variable, so i can add/subtract/multiply/ etc them.
(x=2,y=3;)
help will be hugely appreciated (self-teaching beginner here)
Do:
int[] intArray = "Cheese23".Where(Char.IsDigit).Select(c => int.Parse(c.ToString())).ToArray();
This extracts the numbers in the string in the order and creates an array out of it.
Then you can do intArray[0] to get 2 and intArray[1] to get 3.
Search up LINQ to see how those chain of methods did it.
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
.NET String.Format() to add commas in thousands place for a number
Hi Guys,
I have got 26750 in my string variable, something like below:
string str = "26750";
Now before showing on page, I want it to be converted into "26,750" format using c#. This value can increase as well as decrease also according to the result, so my format should work in both the cases.
Please suggest!
EDIT:
As I have written I have got string type value in my variable, I am trying with below code, but it is not working for me.
spnMiles.InnerHtml = String.Format("{0:n}", Miles);
It is not changing to the number format.
Please suggest!
This question should answers yours:
.NET String.Format() to add commas in thousands place for a number
This question already has answers here:
Is it possible to pad integers with zeros using regular expressions?
(2 answers)
Closed 9 years ago.
I am trying to display a code like ABC/DEF/00012 or ABC/EDF/01234 or ABC/DEF/00009
I use RegEx mask \w{3}/\w{3}/?????
The question mark is hard part that I could not figure it out.
Basically, I try to display the code with characters and numbers. I want to automatically add leading zeros on the number.
Byron
Seems that you're trying to match 5 digits at the end:
\w{3}/\w{3}/\d{5}