前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >C#几行代码干掉一台电脑[无限弹窗]

C#几行代码干掉一台电脑[无限弹窗]

作者头像
A-My
发布2022-09-19 15:10:27
4730
发布2022-09-19 15:10:27
举报
文章被收录于专栏:A-My

使用C#中的Windows窗体应用程序写一个无限弹窗

  • 第一步:打开Visual Studio新建项目
  • 第二部:简单设计一下窗体后打开Program.cs文件
  • 第三步:编写以下代码:
代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace UnlimitWind
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());

            while (true)
            {
                Form1 form1 = new Form1();
                form1.Show();
            }
        }
    }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace UnlimitWind
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());

            while (true)
            {
                Form1 form1 = new Form1();
                form1.Show();
            }
        }
    }
}

注意一定要把Application.Run(new Form1());这行代码删除或注释掉 原理:用一个while(true)无限循环来创建窗体对象,对象名.Show()方法不断地打开窗体

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-05-21,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档