Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#控制台应用程序中的宏_C#_Console_Codepages_Ascii Art - Fatal编程技术网

c#控制台应用程序中的宏

c#控制台应用程序中的宏,c#,console,codepages,ascii-art,C#,Console,Codepages,Ascii Art,我正在尝试使用斜线和破折号创建一个堡垒,我需要使用一个宏(overscore)。我试过几种方法,但都不管用。有什么办法让它工作吗?我得到的不是马克龙,而是“?” using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace kingsdom { class Program {

我正在尝试使用斜线和破折号创建一个堡垒,我需要使用一个宏(overscore)。我试过几种方法,但都不管用。有什么办法让它工作吗?我得到的不是马克龙,而是“?”

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

namespace kingsdom
{
    class Program
    {
       static void Main(string[] args)
       {
           int n = int.Parse(Console.ReadLine());
           string ups = new string ('^', n / 2);
           string midUps = new string('_' ,(n * 2) - (((n / 2) * 2) + 4));
           string whitespaces = new string(' ', (n * 2) - 2);
           string downs = new string('_', n / 2);
           string midDowns = new string('\u203E', (n * 2) - (((n / 2) * 2) +    4));
           Console.WriteLine("{0}{1}{2}{3}{0}{1}{2}", "/", ups, "\\", midUps);
           for (int i = 0; i < n - 2; i++)
           {
               Console.WriteLine("{0}{1}{0}", "|", whitespaces);
           }
           Console.WriteLine("{0}{1}{2}{3}{0}{1}{2}", "\\", downs, "/", midDowns);
       }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
名称空间kingsdom
{
班级计划
{
静态void Main(字符串[]参数)
{
int n=int.Parse(Console.ReadLine());
字符串ups=新字符串(“^”,n/2);
字符串MIDUP=新字符串(“”,n*2)-(n/2)*2)+4);
字符串空白=新字符串(“”,(n*2)-2);
字符串向下=新字符串(“n/2”);
字符串长度=新字符串('\u203E',(n*2)-(n/2)*2)+4);
WriteLine(“{0}{1}{2}{3}{0}{1}{2}”,“/”,ups,“\\”,midUps);
对于(int i=0;i
控制台可以使用不同的代码页来显示文本。并非所有这些代码页都能正确显示所有字符。例如,当您使用代码页855(这是使用东欧语言和西里尔字母的Windows系统的默认设置)时,无法显示宏字符

您可以通过在主功能的开头设置
console.outpunecoding
来定义用于您自己的控制台输出的代码页:

Console.OutputEncoding = Encoding.Unicode;
这将使控制台能够显示任何Unicode字符

如果您想使用特定的代码页,例如437(美国),您可以编写:

Console.OutputEncoding = Encoding.GetEncoding(437);
请注意,在此处使用
Encoding.Unicode
至少需要.net版本4.5


有关详细信息,请参阅。

您的问题到底是什么?您的代码对我来说似乎很好。@Chris而不是Macron,我得到“?”这可能意味着您的字体不支持该字符。尝试它将工作(你的浏览器可能有Unicode字体)。也考虑编辑你的问题包含你的问题的细节。问题应该有一个清晰的陈述,说明你预期会发生什么以及实际发生了什么,而不需要人们在评论中搜索信息。这当然可以避免我在编译和运行代码时浪费时间。@Chris有办法在我的计算机上运行它吗?