Convert Numerical Digits in Vocabulary Forms [duplicate] - c#

This question already has answers here:
How can I convert an integer into its verbal representation?
(16 answers)
Closed 7 years ago.
How can I convert final amount of billing to it's related vocabulary form?
I am trying to develop a function which convert it in vocabulary form.
For, ex. 12345 Rs. then it's output should be like this
TWELVE THOUSAND THREE HUNDRED N FORTY FIVE ONLY
is it possible with few easy steps in C# ?

If you are willing to use an external library, i'd suggest you try out Humanizer
Really simply to use and your example would be as simple as.
12345.ToWords(); //it adds extension methods that achieve this.

Related

How to add zeroes Infront of an integer in c# [duplicate]

This question already has answers here:
Convert integer to binary in C#
(22 answers)
C# convert int to string with padding zeros?
(15 answers)
Closed 2 days ago.
I have a data I'm getting using my form and then I need to send it to a different software as an 8 digits number (in binary) the problem is the zeroes that come before the first '1' to appear in the data disappear.
for example:
the number 3 in binary is 00000011 so what will be send is 11
the letter A in binary is 01000001 so what will be send is 1000001
I need a code that will recognize how many digits in my data and add zeroes in front until the number would be 8 digits in c#
I looked online but all I could find is adding two known integers together but since I don't know how many digits would be missing from my data (as I don't know what the data would be yet, depends on the user), I can't use that.

How to convert numerical value to words? [duplicate]

This question already has answers here:
How can I convert an integer into its verbal representation?
(16 answers)
.NET convert number to string representation (1 to one, 2 to two, etc...)
(11 answers)
Closed 8 years ago.
Hey anyone know about a function in C# that converts numerical value in to words
Like If I give Input: 53904
Then the output should be: FIFTY THREE THOUSAND NINE HUNDRED FOUR ONLY
By far, the best solution for this is the .NET Humanizr. It installs a series of extension methods and you can use it just like this:
15.ToWords(); // Returns "Fifteen"
int i;
i = 1587;
i.ToWords(); // Returns "One Thousand Five Hundred and Eighty Seven"
This works not only for numbers, but it works on DateTime, TimeSpan, Enums and others. I have used it in one of projects and it works great!
In addition, it has several other language translations, so it'll work in other languages, if you need it to.

mobile number length based on the country name selected in the dropdown [duplicate]

This question already has answers here:
RegEx for valid international mobile phone number [duplicate]
(6 answers)
Closed 9 years ago.
In my asp.net application, I have to use the validation for mobile number length based on the country name selected in the dropdown.
I have googled for the solution, but couldn't able to find exact one.
Can anybody share the usefull link or info to me?
Short answer:
You can't (unless you're limited to a very specific subset of countries).
Long answer:
Telephone systems are too varied and - in short - non-standardized to create one "catch all" solution.
While some countries, like the US, got fixed length numbers, others, e.g. Germany, got variable lenghts.
For example, the area code for landlines in Germany is always 5 digits long (4 digits if you're calling from another country). However, for mobile phones it's always 4 digits (3 digits calling from another country).
The actual (local) phone number then can be anything from 3 digits up to 7 or more.
My parents have a telephone they've got ages ago - 4 digits (9 digits total with area code). If I'd get a new contract today, I'd most likely end up with 6 or 7 digits (12+ digits total).
What you could do
Rather than checking for complete numbers, you could try to use a regular expression (see Shekhar's comment above) to verify a proper formatting (e.g. to include the country selection). While this isn't a perfect solution, it should help you avoiding confusing input users left by accident.

How can I check the input if it's nearly same or not? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Are there any Fuzzy Search or String Similarity Functions libraries written for C#?
I need to check the similarity of input value -which one user entered- to our records.
12345 vs 1234
12345 vs 13245
Robert vs Robret
etc...
In short; I need to calculate the similarity and tolerate the input in some ratio...
The Levenshtein distance is a string similarity algorithm you could use.
Google shows me this
I think you might be looking for an Edit Distance algorithm.

Format number with comma separator for thousands using C# [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
String.Format an integer to use 1000's separator without decimal places or leading 0 for small integers
The blog post
http://blog.stevex.net/string-formatting-in-csharp/
(in the Custom number formatting section) shows that using the format {0:0,0}, a number like 1500 will be formatted as 1,500 which is good. But I don't understand why 0 is formatted as 00
Do I need to handle the case of 0 separately which doesn't seem to be necessary.
You can use "F0", which is "fixed number with 0 decimal places". It give you a thousands separator when you results go over 1,000.

Categories

Resources