Useful .Net stuff often overlooked
Ok, I need to write it down somewhere, the article has a lot of explanations, and I just want to record classes because I know what they are, but I will forget later.
The article is here: http://haacked.com/archive/2007/06/13/the-most-useful-.net-utility-classes-developers-tend-to-reinvent.aspx
Stuff to remember:
Combine path:
From comments:
Check if var is a number: Double.TryParse or Int.TryParse
Timing execution (not sure, but that's what it sounds like from the comment):
System.Diagnostics.Stopwatch
Query string: HttpUtility.ParseQueryString
Raw URL: HttpContext.Current.Request.RawUrl; (MSDN)
The article is here: http://haacked.com/archive/2007/06/13/the-most-useful-.net-utility-classes-developers-tend-to-reinvent.aspx
Stuff to remember:
Combine path:
public string GetFullPath(string filename)Get folder location:
{
string folder = ConfigurationManager.AppSettings["somefolder"];
return System.IO.Path.Combine(folder, filename);
}
someFolderPath + Path.DirectorySeparatorChar;Get just the file name:
string fileName = Path.GetFileName(fullPath);Get absolute path from virtual:string path = VirtualPathUtility.ToAbsolutePath("~/Controls/Test.ascx");Get new line separator (really neat one!) Environment.NewLine;
From comments:
Check if var is a number: Double.TryParse or Int.TryParse
Timing execution (not sure, but that's what it sounds like from the comment):
System.Diagnostics.Stopwatch
Query string: HttpUtility.ParseQueryString
Raw URL: HttpContext.Current.Request.RawUrl; (MSDN)
Labels: c# .net programming

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home