Click here to Skip to main content
15,904,497 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Here is the VB.NET code:

VB
[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


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#.

C#
[System.Configuration.ApplicationScopedSettingAttribute(),
System.Diagnostics.DebuggerNonUserCodeAttribute(),
System.Configuration.DefaultSettingValueAttribute("FinDBLogRec_")]
public string LogFileNamePrefix 
{
    get { return Convert.ToString(this("LogFileNamePrefix")); }
}
Posted
Updated 16-Feb-11 8:09am
v2

I guess you'd need this["string"] instead of this("string") in C#. Doing that may fix both errors, provided you have implemented the indexer.
 
Share this answer
 
v2
Comments
MacIntyre 16-Feb-11 14:25pm    
Thanks we are half way there. It fixed the this bot ont Convert..
Nish Nishant 16-Feb-11 14:27pm    
What's the exact error you get for the Convert call? You may need to prefix the namespace (System).
MacIntyre 16-Feb-11 14:34pm    
I included System and that cleared up the Convert..
Thanks to all..
Nish Nishant 16-Feb-11 14:44pm    
You're welcome.
Espen Harlinn 16-Feb-11 15:12pm    
Good reply, nicely spotted - my 5
Why don't you just just

C#
get { return MyApp.Settings.LogNamePrefix; }
 
Share this answer
 
Comments
MacIntyre 16-Feb-11 14:29pm    
This sounds like a great idea, and being new to C# I see a lot of "MyApp.Settings...." statements. The problem I'm dealing with is it can't find "Settings". Where can I read about the importance and/or purpose for the thing called Setting and where does it go in the program?
thanks...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900