C# แปลง String ตัวอักษรให้เป็น ตัวเลข int Number (C#.NET)
Tag : .NET, C#
Date :
2011-12-03 06:52:32
By :
agent
View :
4093
Reply :
1
No. 1
Guest
Code (C#)
int numVal = Int32.Parse("-105");
Console.WriteLine(numVal);
Code (C#)
// TryParse returns true if the conversion succeeded
// and stores the result in the specified variable.
int j;
bool result = Int32.TryParse("-105", out j);
if (true == result)
Console.WriteLine(j);
else
Console.WriteLine("String could not be parsed.");
// Output: -105