Passing values to a property in C#?



I am converting an application I wrote in VB.NET to C#. I am not a C#
guy, at all. I am having a problem passing values to a property in C#.
I understand that it is probably not the best way of achieving my
result, but it works in VB.NET, flawlessly.

Basically, I am storing a bunch of settings in a hashtable. Then,
setting/getting my values in the hastable with a public shared
property. Below is the property. The function GetSetting's return will
look similiar to this....

Return System.Web.HttpContext.Current.Application("config")(item)


Public Shared Property Settings(ByVal Item As String) As String

Get
Return CType(GetSetting(Item), String)
End Get

Set(ByVal Value As String)

Try


System.Web.HttpContext.Current.Application("config")(Item) = Value

Catch ex As Exception

GetSetting(Item)

System.Web.HttpContext.Current.Application("config")(Item) = Value

End Try

End Set

End Property


When I convert to C#, Visual Studio is screaming at me. And here is my
C# version....

public static string Settings(string Item)
{
get
{
return ((string)(GetSetting(Item)));
}
set
{
try
{

System.Web.HttpContext.Current.Application["config"][Item] = value;
}
catch (Exception ex)
{
GetSetting(Item);

System.Web.HttpContext.Current.Application["config"][Item] = value;
}
}
}


If it was simply rewriting a few lines of code, I wouldn't have even
posted here. But, again, this is my method of setting/getting all my
application variables. So, if I have to change the way I am doing this,
I will have to do it everywhere in the application. Please help! :(

.



Relevant Pages

  • Re: Passing values to a property in C#?
    ... I am having a problem passing values to a property in C#. ... Public Shared Property Settings(ByVal Item As String) As String ... Catch ex As Exception ... But, again, this is my method of setting/getting all my ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Detailed ASP.Net info not displaying in browser
    ... HTTP 500 page when an exception is thrown from the web service. ... at VOSE.Data.DataRequest.dr_DB2Process.DeleteCommRows(String company, String ... objQueue, tOrderManagementIndicator omindicator, Int32 intTriggerId) in ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.xml)
  • RE: Detailed ASP.Net info not displaying in browser
    ... HTTP 500 page when an exception is thrown from the web service. ... at VOSE.Data.DataRequest.dr_DB2Process.DeleteCommRows(String company, String ... objQueue, tOrderManagementIndicator omindicator, Int32 intTriggerId) in ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.xml)
  • Re: App_data - ASPNETDB.MDF
    ... is only because I want my site work, without exception. ... Server Error in '/' Application. ... serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Could not load file or assembly...
    ... The problem shows when EL exception handling ... context, ExceptionHandlerData objectConfiguration, IConfigurationSource ... configurationSource, ConfigurationReflectionCache reflectionCache) ... context, String name, IConfigurationSource configurationSource, ...
    (microsoft.public.dotnet.framework)