Tag: C#
-
Display Class Objects in CheckedListBox
If you want to use anything more complex than a list of strings in a ListBox, you’re in luck because the control accepts all types of objects.
-
C#: using Statement
One of my absolute favourite statements in C# is the using statement (not to be confused with the using directive, which is what we use to import libraries like System.Web into our projects).
-
Implementing Lazy Load Using a Proxy Class
Lazy load is a design pattern wherein an object is not instantiated until the last possible minute. This is very handy when working with lists of items whose contents are expensive to retrieve from the data store.
-
CommandEventHandler Event Won't Fire for Button in ASP.NET Custom Control
Problem: I created a custom control with a dynamic button and attached an event handler to that button. When I run the control, clicking the button causes a postback but the event is not fired.
-
What I Learned from MUDs
The first bit of code I ever worked on was ROM 2.4, a text-based MUD server written in C. At the time I didn’t know the first thing about programming, but through trial and error I was able to feel my way around the source code and slowly learn how the language worked and how to make the program do what I wanted. Some experienced programmers called me the “snippet king” because I used a lot of pre-written additions to expand m game, but I see it as part of the learning process. If I were to work on a MUD again, I now have the knowledge to do all of the programming myself - but if it weren’t for my baby steps back then I may never have become a programmer at all.
-
Replacing / Adding Line Breaks in GridView Text
The GridView is a powerful control for quickly and easily displaying tables of data. However, a raw dump of information is not always good - when displayed by a web browser, normal line breaks are simply rendered as spaces.
-
C#: Using Suffixes to Declare Data Literals
This isn’t new, but handy to have. In order to tell the compiler which data type we’re using, we use suffix notation as follows:
-
C#: Finding the Number of Days Between Two DateTime Items
One very common requirement is for the number of days elapsed since a particular Date and Time. In C# this can be accomplished through the use of the TimeSpan class.
-
Handling Relative Paths Programmatically In ASP.NET
One of the nicest features in ASP.NET is its out-of-box support for relative paths in hyper links and other controls. This is very important for developers whose code resides within the root of their testing environment but within a sub-directory of the production server.
-
C#: Instantiating a class of Unknown Type
The project I am currently working on has several dozen different types of Form classes, each of which is accessible from a common menu strip. Rather than repeatedly instantiating each of the forms from the menu item handlers, I wanted to funnel the request to a single function.
-
C#: Form.Close() vs Form.Dispose()
When working with a Windows GUI, it may seem unclear whether to use Form.Close() or Form.Dispose() to get rid of a dialog at runtime.