什么是一个转换的正确方法char来int?这给出了49:
int val = Convert.ToInt32('1');
//int val = Int32.Parse("1"); // Works
Run Code Online (Sandbox Code Playgroud)
我不想转换为字符串,然后解析它.
当我使用Convert.toint32解析字符串时,我得到了奇怪的数字
var check = "82567";
Convert.ToInt32(check[0]) //I get 56
Convert.ToInt32(check[0].ToString());// I get 8
Run Code Online (Sandbox Code Playgroud)
有人可以帮我理解这一点吗
我想从字符串中获取数字,我做了.
我想将此char转换为数据库的任何interger,但会出现以下错误:'/'应用程序中的服务器错误.
输入字符串的格式不正确.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a correct format.
Run Code Online (Sandbox Code Playgroud)
码:
For Each File As FileInfo In New DirectoryInfo(("C:\Folder")).GetFiles("*.aspx", SearchOption.AllDirectories)
vFileName = File.FullName
Dim myChars() As Char = vFileName.ToCharArray()
Dim iChar As Integer = Convert.ToInt32(myChars)
iChar = Mid(1, 1, iChar)
Run Code Online (Sandbox Code Playgroud)