开发者

How to perceive in code if developer pressed F5 or Ctrl-F5

开发者 https://www.devze.com 2023-03-04 23:33 出处:网络
How can I perceive in code (C#) if developer pressed F5 or Ctrl-F5 prio开发者_开发百科r to execute solution in VS2010?

How can I perceive in code (C#) if developer pressed F5 or Ctrl-F5 prio开发者_开发百科r to execute solution in VS2010?

if (F5Pressed) {do something} else {do some other thing}


static void Main(string[] args)
{

    if (System.Diagnostics.Debugger.IsAttached)
       Console.WriteLine("f5");
     else
       Console.WriteLine("ctrl f5");
    string s = Console.ReadLine();

}

This works in the general case, but is not exactly what you asked for. As other debuggers could be attached, also if you just run the exe by double clicking it will report that crtl f5 was pressed.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号