• <bdo id='6diMs'></bdo><ul id='6diMs'></ul>

      <i id='6diMs'><tr id='6diMs'><dt id='6diMs'><q id='6diMs'><span id='6diMs'><b id='6diMs'><form id='6diMs'><ins id='6diMs'></ins><ul id='6diMs'></ul><sub id='6diMs'></sub></form><legend id='6diMs'></legend><bdo id='6diMs'><pre id='6diMs'><center id='6diMs'></center></pre></bdo></b><th id='6diMs'></th></span></q></dt></tr></i><div id='6diMs'><tfoot id='6diMs'></tfoot><dl id='6diMs'><fieldset id='6diMs'></fieldset></dl></div>

    1. <legend id='6diMs'><style id='6diMs'><dir id='6diMs'><q id='6diMs'></q></dir></style></legend>

        <tfoot id='6diMs'></tfoot>

        <small id='6diMs'></small><noframes id='6diMs'>

      1. 如何在 C# 控制台应用程序中绘制方框、矩形

        时间:2023-09-14

          <legend id='gNcTJ'><style id='gNcTJ'><dir id='gNcTJ'><q id='gNcTJ'></q></dir></style></legend>

              1. <i id='gNcTJ'><tr id='gNcTJ'><dt id='gNcTJ'><q id='gNcTJ'><span id='gNcTJ'><b id='gNcTJ'><form id='gNcTJ'><ins id='gNcTJ'></ins><ul id='gNcTJ'></ul><sub id='gNcTJ'></sub></form><legend id='gNcTJ'></legend><bdo id='gNcTJ'><pre id='gNcTJ'><center id='gNcTJ'></center></pre></bdo></b><th id='gNcTJ'></th></span></q></dt></tr></i><div id='gNcTJ'><tfoot id='gNcTJ'></tfoot><dl id='gNcTJ'><fieldset id='gNcTJ'></fieldset></dl></div>
                  <bdo id='gNcTJ'></bdo><ul id='gNcTJ'></ul>
                • <tfoot id='gNcTJ'></tfoot>

                  <small id='gNcTJ'></small><noframes id='gNcTJ'>

                    <tbody id='gNcTJ'></tbody>
                  本文介绍了如何在 C# 控制台应用程序中绘制方框、矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我问了两个相关的问题.

                  I ask for 2 related questions.

                  1-我们如何将输出(例如结果和消息)放入 c# 控制台应用程序的框内.

                  1-How we can Put outputs(such as Results and Messages) inside a box in a c# console application.

                  2-我们如何在 c# 控制台应用程序中绘制矩形.感谢您提供任何示例教程或建议

                  2-How we can draw rectangle in a c# console application.thank u for any sample tutorial or advice

                  推荐答案

                  假设你的意思是一个字符框,这就可以了.

                  Assuming you just meant a character box this will do it.

                   private static void DrawABox( int x, int y, int width, int height,char Edge,string Message )
                      {
                          int LastIndex =0 ;
                          Console.SetCursorPosition(x, y);
                          for ( int h_i = 0; h_i <= height ; h_i++ )
                          {
                              if ( LastIndex != -1 )
                              {
                                  int seaindex = (LastIndex + ( width - 1) );
                                  if(seaindex >= Message.Length -1 )
                                      seaindex = Message.Length - 1;
                                  int newIndex = Message.LastIndexOf(' ',seaindex);
                                  if(newIndex == -1 )
                                      newIndex = Message.Length - 1;
                                  string substr = Message.Substring(LastIndex, newIndex - LastIndex);
                                  LastIndex = newIndex;
                                  Console.SetCursorPosition(x + 1, y + h_i);
                                  Console.Write(substr);
                              }
                              for ( int w_i = 0; w_i <= width; w_i++ )
                              {
                  
                                  if ( h_i % height == 0 || w_i % width == 0 )
                                  {
                                      Console.SetCursorPosition(x + w_i, y + h_i);
                                      Console.Write(Edge);
                                  }
                  
                  
                              }
                  
                          }
                  

                  我编辑了代码以在其中添加一条消息.您将需要在边界条件上做更多的工作.例如,消息中没有空格,一个比方框长的词,但这应该足以让你开始.

                  I edited the code to put a message in their. You will need to do more work on the boundary conditions. Ex no space in the message a word that is longer then the box but this should be enough to get you started.

                  这篇关于如何在 C# 控制台应用程序中绘制方框、矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:“选择文件夹对话框"在 .NET 中 下一篇:您可以访问标准的 Windows 字符串,如“取消"吗?

                  相关文章

                    1. <small id='rjzx2'></small><noframes id='rjzx2'>

                    2. <legend id='rjzx2'><style id='rjzx2'><dir id='rjzx2'><q id='rjzx2'></q></dir></style></legend>
                        <bdo id='rjzx2'></bdo><ul id='rjzx2'></ul>

                      <tfoot id='rjzx2'></tfoot>

                      <i id='rjzx2'><tr id='rjzx2'><dt id='rjzx2'><q id='rjzx2'><span id='rjzx2'><b id='rjzx2'><form id='rjzx2'><ins id='rjzx2'></ins><ul id='rjzx2'></ul><sub id='rjzx2'></sub></form><legend id='rjzx2'></legend><bdo id='rjzx2'><pre id='rjzx2'><center id='rjzx2'></center></pre></bdo></b><th id='rjzx2'></th></span></q></dt></tr></i><div id='rjzx2'><tfoot id='rjzx2'></tfoot><dl id='rjzx2'><fieldset id='rjzx2'></fieldset></dl></div>