Mr. Softwarepants

( March 17th, 2006 )

 
Python/Django/.NET/C#/Database project? Hire me.
17
Mar
2006

C#: Barenaked Properties?

Keith asks why, why, why would someone write a class full of properties that access a private member but have no custom behavior.

I agree with him up to a point, and that point is "WinForms Data Binding".

Properties and member fields are treated differently by System.Reflection. You can databind to an object property, but not a plan old member. Assuming a form with a button and a text field, the code below will throw an exception when you click the button:

using System;
using System.Windows.Forms;

namespace BindingTest
{
	public partial class Form1 : Form
	{
		DataStuff stuff;
		public Form1()
		{
			InitializeComponent();
			stuff = new DataStuff();
		}

		private void button1_Click(object sender, EventArgs e)
		{
			textBox1.DataBindings.Add("A", stuff, "Text");
		}

		class DataStuff
		{
			public string A;
			public string B;

			public DataStuff()
			{
				this.A = "Abcde";
				this.B = "Defgh";
			}
		}
	}
}


You can't data bind to a public member. Though if you wanted to get really gross you could fake it by implementing your own Type Descriptor that synthesized properties, but we're not going to go there.
Famfamfam Silk icons, now at version 1.3 and called "complete".

The Cancel icon is redder (and uglier) than in 1.2.
Good Experience: A new outlook on technology.
And he stands there showing me this demo, very nice guy, pecking out each - letter - on - the - keyboard - with - one - single - finger. And I thought, you just spent a year of your life creating a tool to fly around information more quickly - and yet you could double your productivity by just learning how to type.
Software As She’s Developed: Dynamic Favicons.

It seems that using the DOM to remove and re-add a favicon <link> will change the image, at least in Firefox. Which means you can get the icon for your page on a tab to do a little jig while someone is reading a different tab.

This sounds like a completely terrible feature.

Later: Apparently you can already use animated gifs. The first one I've seen is at GPSoftware.

Previous Day [Archive] Next Day
 
View my:
Reads
Links
Photos
Website
LinkedIn
Last.fm
GM scripts
Twits
Google Code
GitHub
Wiki

The Piehead News
(C) 2003-2008
Adam Vandenberg