Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to check weather our string contain same number or not
Posted
Comments
Bojjaiah 2-Mar-12 6:07am    
example?

Convert the number to string and check
 
Share this answer
 
Comments
johannesnestler 2-Mar-12 7:42am    
you mean: convert your string to a number and then just compare, dont you?
ProEnggSoft 2-Mar-12 8:48am    
I mean the other way. Convert the number to string format and then compare.
C#
using System;

public class IsNumberSample {
    public static void Main() {
        string str = "non-numeric";

        Console.WriteLine(Char.IsNumber('8'));      // Output: "True"
        Console.WriteLine(Char.IsNumber(str, 3));   // Output: "False"
    }
}
 
Share this answer
 
try this:
C#
using System.Text.RegularExpressions; 
....
string comparestring = "888555"; 
string ourstring ="whatever string characters or numbers! like aaabbb or 888555"
string newstring = Regex.Match(ourstring, @"[\d]*").Value;
if(comparestring == newstring )
{
textbox1.text = newstring;
} 
//your result = 888555
 
Share this answer
 
v2

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