常见的一些tips

今天算是完成了最最简略的特征矩阵提取。其实呢,就是一个与数学相关的问题,C#并没有利用到很深的地步。

1 Console.Write("{0:F2}", eigenMatrix[i][j]); //输出流的字符串格式化

但是找到了一个颇有用的东西,可以供日后慢慢研究(调整控制台窗体在屏幕中的位置):

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;


namespace ConsoleApplication10
{
  class Program
  {
    const int SWP_NOSIZE = 0x0001;


    [DllImport("kernel32.dll", ExactSpelling = true)]
    private static extern IntPtr GetConsoleWindow();

    private static IntPtr MyConsole = GetConsoleWindow();

    [DllImport("user32.dll", EntryPoint = "SetWindowPos")]
    public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags);

    static void Main(string[] args)
    {
      int xpos = 300;
      int ypos = 300;
      SetWindowPos(MyConsole, 0, xpos, ypos, 0, 0, SWP_NOSIZE);
      Console.WriteLine("any text");
      Console.Read();
    }
  }
}

 在程序块中要善用throw和catch,throw中写的是错误提示信息,catch用来捕捉,try用来执行。

posted @ 2015-03-30 15:49  Jingchao1902  阅读(159)  评论(0)    收藏  举报