DNS Suffix Country Codes
Have you ever wondered where ‘.bz’ was?
(One of the last snippets from CodeKeep.)
I’ve got a console app that I am using to test NHibernate. The app fails to run because I can’t get connected to my local db. After checking the current user at runtime, I realized there wasn’t any defined user which messes up my db connection.
Here is a work-around.
(Another snippet I originally posted to CodeKeep.)
(Another snippet I originally posted to CodeKeep.)
Format a datetime value within a gridview’s boundfield control. The default shows MM/dd/yyyy hh:mm:ss. In my case, I didn’t want/need the time portion. So…
<asp:BoundField DataField="timestamp" DataFormatString="{0:MM/dd/yyyy}" HeaderText="Date entered" />
Reference:
http://forums.microsoft.com/hongkong/ShowPost.aspx?PostID=4003043&SiteID=82
(Another snippet I originally posted to CodeKeep.)
After you finish modifying text within a RichTextBox control, you may want to move the cursor to the top of the control.
Code:
richTextBox1.SelectionStart = 0; richTextBox1.SelectionLength = 0;
(Another snippet I originally posted to CodeKeep.)
I needed to create a RichTextBox with a title, menu path, and description. Here’s how I made customized the visuals to suit the project. Title is enlarged and made bold. Menu is reduced and made italics. The description is ‘standard.’
Code:
(Another snippet I originally posted to CodeKeep.)
Code:
var myList = new List<string>() { "one", "two", "three" }; // print out the original list foreach (string item in myList) Console.WriteLine(item); // one two three myList.Remove("two"); // print out the new list foreach (string item in myList) Console.WriteLine(item); // one three
Notes:
You cannot remove items from a list inside of a foreach. You can set items to null, but you cannot remove the items.
(Another snippet I originally posted to CodeKeep.)
public enum EFileType
{
Unknown = –1,
Test,
Production
}
...
var fileType = EFileType.Production;
var str = Enum.GetName(typeof(EFileType),fileType); // str == 'Production'
(Another snippet I originally posted to CodeKeep.)
I needed to do a secure file copy to a remote server for an activity report. I chose to use pscp from PuTTY.
(Another snippet I originally posted to CodeKeep.)
Using ‘this’ can make your code simpler and easier to read.
Here is a hard way to create a pair of constructors:
(Another snippet I originally posted to CodeKeep.)
Need the path to the local temp folder or a temp file name to store some runtime junk?
Look no further…
var tempPath = System.IO.Path.GetTempPath();
var tempFile = System.IO.Path.GetTempFileName();
(Another snippet I originally posted to CodeKeep.)
I’d recommend looking at EntLib 5.0 if you are serious about your event logging. This is but a simple hack…
(Another snippet I originally posted to CodeKeep.)
Code:
interface IPlural
{
void Load();
void Load(ELoadOptions option, int id);
}
interface IMembership
{
void Save();
void Delete();
void Load(int id);
}
Usage:
public class CAddresses : List<CAddress> , IPlural
{
public void Load()
{
// do something
}
public void Load(ELoadOptions option, int id)
{
// do something
}
}