zoukankan      html  css  js  c++  java
  • 《21天学通C#》将写的代码原封不动的在控制台显示

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.IO;

    namespace 第二天课程课后习题
    {
    class Program
    {
    static void Main(string[] args)
    {
    try
    {
    int ctr = 0;
    if(args.Length<=0)
    {
    Console.WriteLine("Format:ListIT filename");
    }
    else
    {
    FileStream f = new FileStream(args[0],FileMode.Open);
    try
    {
    StreamReader t = new StreamReader(f);
    string line;
    while((line=t.ReadLine())!=null)
    {
    ctr++;
    Console.WriteLine("{0}:{1}", ctr, line);
    }
    f.Close();
    }
    finally
    {
    f.Close();
    }
    }
    }
    catch(System.IO.FileNotFoundException)
    {
    Console.WriteLine("ListIT could not find the file", args[0]);
    }
    catch(Exception e)
    {
    Console.WriteLine("Exception:{0} ", e);
    }
    Console.WriteLine("请按任意键退出程序!");
    Console.ReadKey();
    }
    }
    }

    然后打开VS 2017开发人员命令提示符,切换到Program.cs所在目录,输入csc Program.cs

    然后再次输入Program Program.cs

    如图所示:

    会显示出所写代码

  • 相关阅读:
    css
    js
    css3
    css
    深浅拷贝
    index-数据结构/算法
    es6知识点
    在vscode中配置sass savepath
    计算机基础
    element-ui使用后手记
  • 原文地址:https://www.cnblogs.com/nnty/p/9909529.html
Copyright © 2011-2022 走看看