gpt4 book ai didi

c# - (type)objectname.var 中的 (type) 是什么

转载 作者:太空狗 更新时间:2023-10-30 00:04:00 25 4
gpt4 key购买 nike

我正在阅读一本关于 C# 的书,遇到了一些我似乎无法查找的东西,因为我不知道它叫什么,或者试图通过描述搜索一些东西。

有人可以向我解释发生了什么,或者在对象引用之前出现的 (type) 背后的含义,如 (int)objectname.variablename?

这对我来说就像是转换。

编辑:由于当我只是猜测并且需要更多代码时,你们中的大多数人都不再引用“我的”类型转换,所以我包括了我正在审查的代码,这些代码带来了这个问题。我在质疑 (int)numericupDown1.Value 中的 (int);

private void numericUpDown1_ValueChanged(object sender, EventArgs e) 
{
dinnerParty.NumberOfPeople = (int)numericUpDown1.Value;
DisplayDinnerPartyCost();
}

最佳答案

它正在转换,它试图在运行时将变量名转换为类型(type)

关于c# - (type)objectname.var 中的 (type) 是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3166349/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com