将VB转换为C#时出错

时间:2016-06-10 08:33:02

标签: c# wpf vb.net

我已将部分VB代码转换为C#

现在代码在某些行上抛出错误。有人可以帮助我知道如何解决这些问题。

_with16.ConcaveColor = System.Drawing.ColorTranslator.FromOle(Interaction.GetSetting(My.Application.Info.Title, "ProfileViewPlotOptions", "BackColor", System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Lime).ToString()));
_with22.Acceleration = Convert.ToDouble(Interaction.GetSetting(My.Application.Info.Title, "FTS1000", "Acceleration", Convert.ToString(200000)));

据我所知,C#中不支持“我的”关键字。有没有可以使用的替代方案

1 个答案:

答案 0 :(得分:1)

My是一个Visual Basic的东西。如果只有这两行产生问题,您可以将其替换为:

var title = ((AssemblyTitleAttribute) System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0]).Title;

_with16.ConcaveColor = System.Drawing.ColorTranslator.FromOle(Interaction.GetSetting(title, "ProfileViewPlotOptions", "BackColor", System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Lime).ToString()));
_with22.Acceleration = Convert.ToDouble(Interaction.GetSetting(title, "FTS1000", "Acceleration", Convert.ToString(200000)));

My.Application.Info.Title提供TitleAssemblyTitleAttribute的值(MSDN链接herehere