Posts
[C#][VB.NET]擴充方法 (Extension Method)
public static class EnumExtension { public static string GetName(this Enum e) { return Enum.GetName(e.GetType(), e); } } class Program { static void Main(string[] args) { Console.WriteLine(Grade.APlus.GetName()); } }</pre></div> Enum Grade APlus A B C D End Enum
Module Module1 Sub Main() Console.WriteLine(Grade.APlus.GetName) End Sub End Module
Module EnumExtension <Extension()> _ Public Function GetName(ByVal e As [Enum]) As String Return [Enum].GetName(e.GetType, e) End Function End Module
class Program { static void Main(string[] args) { string str = null; Console.
read morePosts
[Performance][C#]StringBuilder與String.Join串接字串時的效能比較
namespace ConsoleApplication17 { class Program { static void Main(string[] args) { int testTimes = 10; int dataCount = 1000000; GoTest(dataCount, testTimes); }
static void GoTest(int dataCount,int testTimes) { //Let JIT compiler precompiler Test1(1); Test2(1); //Test performance Stopwatch sw; long[] elapsedTimes = new long[testTimes]; Console.WriteLine("String.Join..."); for (int i = 0; i < testTimes; i++) { sw = Stopwatch.StartNew(); Test1(dataCount); elapsedTimes[i] = sw.ElapsedMilliseconds; Console.WriteLine("Elapsed Time: " + elapsedTimes[i]); } Console.WriteLine("Average Elapsed Time: " + elapsedTimes.
read morePosts
[VB.NET]用.NET實作檔案總管
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /white-space: pre;/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .
read morePosts
[VB.NET]從登錄檔中讀取CPU資訊
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /white-space: pre;/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .
read more