2012-10-15 3 views
0

Numberformat 클래스에 유사한 C# 클래스에있는 클래스는 Java에 있으며 문자열이 숫자인지 확인하십시오.문자열이 C#에서 숫자 (int, long, float 또는 double)를 찾을 수 있습니까?


NumberFormat numberFormat = NumberFormat.getInstance(); 
Number number = numberFormat.parse(string); 
파라미터 float.TryParse (값 fValue 아웃 NumberStyles.Float, CultureInfo.InvariantCulture 등) 다음으로 플로트 동안,

값 = 6666.77777는 6666.778의 반올림된다.

누구든지 도움을 줄 수 있습니다. 내 가치가 반올림되는 것을 원하지 않습니다.

+10

'int.TryParse (...)를 확인하기 위해 원하는 번호 int 교체','float.TryParse (...)','long.TryParse (...)','double.TryParse (...)'... –

답변

6

int.TryParse 숫자가 int이면 true를 반환합니다.

string str = "123"; 
int temp; 
if (int.TryParse(str, out temp)) 
{ 
    //its an int 
} 
else 
{ 
    // not an int 
} 
+1

@Mahmoud Gamal, 서식 지정/편집 해 주셔서 감사합니다. – Habib

-1
int a 
bool isNumber = int.TryParse("500", out a); 

당신이

관련 문제