Tag: C# .NET
プロパティ†
WOW64†
コレクション†
正規表現†
- "(数値)x(数値)"の検索
System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(
@"(?<width>[\d]+)x(?<height>[\d]+)", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Match m = r.Match(s);
if (m.Success)
{
Trace.WriteLine("- Width:" + m.Groups["width"]+ ", Height:" + m.Groups["height"]);
}
インターフェース†
アプリケーション例外補足†
static void Main()
{
...
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
Thread.GetDomain().UnhandledException += new UnhandledExceptionEventHandler(Application_UnhandledException);
...
}
public static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
ShowErrorMessage(e.Exception, "Application_ThreadException error.");
}
public static void Application_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Exception ex = e.ExceptionObject as Exception;
if (ex != null)
{
ShowErrorMessage(ex, "Application_UnhandledException error.");
}
}
Traceをファイル出力†
StreamWriter sw = new StreamWriter("log.txt");
sw.AutoFlush = true;
TextWriter tw = TextWriter.Synchronized(sw);
TextWriterTraceListener twtl = new TextWriterTraceListener(tw, "LogFile");
Trace.Listeners.Add(twtl);
Traceにメソッド名を出力†
Trace.WriteLine(DateTime.Now.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);
文字列†
アセンブリ†
並行処理†
スレッド†