VB.NET到C#.NET,我正在寻找一种替代LogFileNamePrefix或使其工作的方法 [英] VB.NET to C#.NET, I'm looking for a way to replace LogFileNamePrefix or make it work
本文介绍了VB.NET到C#.NET,我正在寻找一种替代LogFileNamePrefix或使其工作的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是VB.NET代码:
Here is the VB.NET code:
[Global.System.Configuration.ApplicationScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("FinDBLogRec_")]
Public ReadOnly Property LogFileNamePrefix() As String
Get
Return CType(Me("LogFileNamePrefix"),String)
End Get
End Property
C#中有一个模拟函数吗?我的转换器创建了以下结果,但编译器不喜欢Convert
或this
.当然,有更好的方法可以在C#中获取此信息.
Is there a simular function in C#? My converter created the following results but the compiler doesn''t like Convert
or this
. Surely there are better ways to get this info in C#.
[System.Configuration.ApplicationScopedSettingAttribute(),
System.Diagnostics.DebuggerNonUserCodeAttribute(),
System.Configuration.DefaultSettingValueAttribute("FinDBLogRec_")]
public string LogFileNamePrefix
{
get { return Convert.ToString(this("LogFileNamePrefix")); }
}
推荐答案
我想您需要在C#中使用this["string"]
而不是this("string")
.如果您已实现索引器,则这样做可以解决这两个错误.
I guess you''d needthis["string"]
instead ofthis("string")
in C#. Doing that may fix both errors, provided you have implemented the indexer.
为什么您不只是
Why don''t you just just
get { return MyApp.Settings.LogNamePrefix; }
这篇关于VB.NET到C#.NET,我正在寻找一种替代LogFileNamePrefix或使其工作的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文