PDA

View Full Version : كمك در تبديل كد به c#



combo_ci
یک شنبه 14 تیر 1388, 10:56 صبح
سلام
من از اين كد توي پروژه هاي vb.net استفاده ميكنم براي reload كردن connectionString توي فايل appconfig
وقتي convert ميكنمش به c# به MySettingsProperty.Settings.Reload گير ميده
كسي ميتونه تبديل اين كد به c# رو دربياره
ممنون

Public Shared Sub ChangeConnectionString(ByVal strConn As String, ByVal Optional ConnectionIndex As Integer = 0)
Dim _config As Configuration = ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None)
If (_config.ConnectionStrings.ConnectionStrings.Count > 1) Then
_config.ConnectionStrings.ConnectionStrings.Item(( ConnectionIndex + 1)).ConnectionString = strConn
_config.Save(ConfigurationSaveMode.Modified)
ConfigurationManager.RefreshSection(_config.Connec tionStrings.SectionInformation.Name)
MySettingsProperty.Settings.Reload
End If
End Sub

jeniferxp
یک شنبه 14 تیر 1388, 13:05 عصر
سلام به این سایت یه سری بزن
http://www.developerfusion.com/tools/convert/vb-to-csharp/

امیدوارم که کمکت کنه

combo_ci
یک شنبه 14 تیر 1388, 13:24 عصر
كدش رو تبديل كردم عزيزم

public static void ChangeConnectionString(string strConn, [Optional, DefaultParameterValue(0)] int ConnectionIndex)
{
System.Configuration.Configuration _config = ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None);
if (_config.ConnectionStrings.ConnectionStrings.Count > 1)
{
_config.ConnectionStrings.ConnectionStrings[ConnectionIndex + 1].ConnectionString = strConn;
_config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(_config.Connec tionStrings.SectionInformation.Name);
MySettingsProperty.Settings.Reload();
}
}



اما به خط
MySettingsProperty.Settings.Reload();


گير ميده

__H2__
یک شنبه 14 تیر 1388, 19:03 عصر
سلام
این در واقع مشکل ذاتی تبدیل کد نیست و فقط یک تغییر نام namespace ساده است که vb.net از نام my استفاده میکند و #c از properties ...


//C#.Net
Properties.Settings.Default.Reload();