Vb 到 C# 的转换混淆——directCast 和 MyBase.Item [英] Vb to c# conversion confusion - directCast and MyBase.Item
本文介绍了Vb 到 C# 的转换混淆——directCast 和 MyBase.Item的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将 vb 转换为 c#,在 c# 中最好的等价物是什么
converting vb to c# , what will be the best equivalent in c# of this
<ConfigurationProperty("name", IsKey:=True, IsRequired:=True)> _
Public Property Name() As String
Get
Return DirectCast(MyBase.Item("name"), String)
End Get
Set(ByVal value As String)
MyBase.Item("name") = value
End Set
End Property
推荐答案
它的返回类型是字符串,只需将其转换为字符串即可.试试下面的代码.
Its return type string, just convert it to string. try the below code.
[ConfigurationProperty("name", IsKey = true, IsRequired = true)]
public string Name
{
get { return (string)base["name"]; }
set { base["name"] = value; }
}
这篇关于Vb 到 C# 的转换混淆——directCast 和 MyBase.Item的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文