我已将部分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#中不支持“我的”关键字。有没有可以使用的替代方案
答案 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
提供Title
中AssemblyTitleAttribute
的值(MSDN链接here和here)