首先先尝试一下最基础的Hello World!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace ConsoleApplication2 { class Program { static void Main(string[] args) { System.Console.WriteLine("Hello World!"); System.Console.ReadLine(); } } }

Readline函数是因为我的控制台不会出现按任意键退出,所以手动补了一个Readline用来查看结果(防止控制台直接闪过去)

之后测试了关于颜色的 BackgroundColor和ForegroundColor

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace ConsoleApplication2 { class Program { static void Main(string[] args) { System.Console.BackgroundColor = ConsoleColor.Green; System.Console.ForegroundColor = ConsoleColor.DarkRed; System.Console.WriteLine("Hello World!"); System.Console.ReadLine(); } } }

效果:

然后又试了一下另开一个类实现输出hello world!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace ConsoleApplication2 { class Program { static void Main(string[] args) { Class1 helloWorld = new Class1(); helloWorld.Hello(); System.Console.ReadLine(); } } } 

Class1:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace ConsoleApplication2 { class Class1 { public void Hello() { Console.WriteLine("Hello World From Class1!"); } } }

其中如果将Hello 函数改成static类型还可以不用实例化就可以调用

如下

main:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace ConsoleApplication2 { class Program { static void Main(string[] args) { Class1.Hello(); System.Console.ReadLine(); } } }

Class1:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace ConsoleApplication2 { class Class1 { public static void Hello() { Console.WriteLine("Hello World From Class1!"); } } }

尝试使用控制台的参数

设置内容:

代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace ConsoleApplication2 { class Program { static void Main(string[] args) { System.Console.WriteLine(args[0] + " " + args[1]); System.Console.ReadLine(); } } }

运行结果

转载于:https://www.cnblogs.com/Durandal/p/4342586.html

最新文章

  1. 详细!看看顶级互联网公司都在研究的无服务器架构!
  2. asyncio 并发测试
  3. IcbcDaemon.exe是什么东西啊?
  4. char p[]与char *p的区别
  5. C语言获取某个分割符之前的内容
  6. 通过javascript在网页端生成zip压缩包并下载
  7. spring异常处理实例(登录例子)
  8. 真相:Java 开发者钟爱 Kotlin 的五个原因
  9. centos7.4装mysql_CentOS7.4用yum安装并配置MySQL5.7
  10. 【lizhi125】比Nero更好用的免费小巧的光盘刻录软件——ImgBurn(中文版)
  11. VS201x+Qt5开发,中文乱码解决
  12. Android多点触摸的判断
  13. 财务分析中三张财务报表计算公式
  14. python matplotlib cannot import name ‘artist‘ from ‘matplotlib‘
  15. 【HBUOJ】暴躁的阿生
  16. 芥川龙之介《烟草与魔鬼》
  17. 客服整理的聊天话术怎么导入到新电脑上面?
  18. React之antd按需加载
  19. 录屏功能怎么打开?检查一下你的电脑这些设置
  20. js实现淡入淡出轮播图

热门文章

  1. Windows防火墙添加80端口,解决apache无法访问的问题
  2. 解决html5中video标签无法播放mp4问题的办法
  3. 解决 sublime text3 运行python文件无法input的问题
  4. object references an unsaved transient instance - save the transient instance before flushing异常问题处理
  5. VS2010无法调试问题解决
  6. webpack-dev-server 设置反向代理解决跨域问题
  7. 解决 Command “python setup.py egg_info“ failed with error code 1 问题
  8. 收到“此应用程序正在从后台线程修改自动布局引擎”错误?
  9. 从另一个调用一个构造函数
  10. win11间歇性卡顿怎么办 windows11间歇性卡顿的解决方法