VB.net to c#遇到问题

yuchangfu 2007-09-20 02:05:56
private Function GetTextProperty(byval controlname as string) as Object
dim objControl as object=me.Controls(controlname)
if objControl isnot nothing then
return objControl.name
endif
end function

本人对C#语法不是很熟悉,将此段翻译成C# 谢谢,
好像C#中对object类型不支持上面写法.
...全文
77 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
北京的雾霾天 2007-09-20
  • 打赏
  • 举报
回复
或者:

private object GetTextProperty(string controlname)
{
if (this.Controls.ContainsKey(controlname))
{
Control ctr = this.Controls[controlname];
return ctr.Name
}
return null;
}
北京的雾霾天 2007-09-20
  • 打赏
  • 举报
回复
private object GetTextProperty(string controlname)
{
if (this.Controls.ContainsKey(controlname))
{
return this.Controls[controlname].Name;
}
return null;
}

111,125

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧