code_junkie

Show Console in Windows Application

Nov 13th, 2011
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. static class Program
  2. {
  3. [STAThread]
  4. static void Main(string[] args) {
  5. bool consoleMode = Boolean.Parse(args[0]);
  6.  
  7. if (consoleMode) {
  8. Console.WriteLine("consolemode started");
  9. // ...
  10. } else {
  11. Application.EnableVisualStyles();
  12. Application.SetCompatibleTextRenderingDefault(false);
  13. Application.Run(new Form1());
  14. }
  15. }
  16. }
  17.  
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Linq;
  21. using System.Text;
  22. using System.Windows.Forms;
  23.  
  24. namespace ConsoleApplication9 {
  25. class Program {
  26.  
  27. [STAThread]
  28. static void Main(string[] args) {
  29.  
  30. if (args.Length > 0 && args[0] == "console") {
  31. Console.WriteLine("Hello world!");
  32. Console.ReadLine();
  33. }
  34. else {
  35. Application.EnableVisualStyles();
  36. Application.SetCompatibleTextRenderingDefault(false);
  37. Application.Run(new Form1());
  38. }
  39. }
  40. }
  41. }
  42.  
  43. using System;
  44. using System.Collections.Generic;
  45. using System.ComponentModel;
  46. using System.Data;
  47. using System.Drawing;
  48. using System.Linq;
  49. using System.Text;
  50. using System.Windows.Forms;
  51.  
  52. namespace ConsoleApplication9 {
  53. public partial class Form1 : Form {
  54. public Form1() {
  55. InitializeComponent();
  56. }
  57.  
  58. private void Form1_Click(object sender, EventArgs e) {
  59. Console.WriteLine("Clicked");
  60. }
  61. }
  62. }
Add Comment
Please, Sign In to add comment