c# - YouTube 上的教程正在使用 CInt 虽然它不存在

标签 c# scripting

你好,最近我决定尝试在不使用 Unity 的情况下制作一些非常小的东西。当我遇到一个将文本更改为整数以进行加法的 YouTube 教程时,它说做

Dim firstNum As Integer = CInt(txtAddVal1.Text)
Dim secondNum As Integer = CInt(txtAddVal2.Text)

我能够根据以前的经验将一些代码更改为 int firstNumber = 我的问题是我不知道如何转换此 CInt变成现在实际存在的变量。我正在使用 Windows App Forms (.NET)。

最佳答案

这里的代码是 VB.NET 而不是 C#。 VB.NET 中的 CInt() 可以替换为 C# 中的 (int)variable

int firstNum = (int)txtAddVal1.Text
int secondNum = (int)txtAddVal2.Text

其他选项是 int.Parse()int.TryParse()

https://www.dotnetperls.com/parse

关于c# - YouTube 上的教程正在使用 CInt 虽然它不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47000415/

相关文章:

Python 2.7 版本没有 http.client 模块

c# - "Deleted row information cannot be accessed through the row"试图从我的数据表中删除未使用的行

C# MYSQL 的安全连接信息

linux - passwd 命令提示用户不存在

google-apps-script - 根据一列删除重复项并在 Google 表格中保留最新条目

javascript - 组合多个 jQuery 脚本

c# - 模板 C#/MVC 4/Razor

c# - 计算存储过程的结果

c# - 在 gridview asp :hyperlinkfield? 上禁用自动回发

windows - python TypeError : must be encoded string without NULL bytes, 不是 str