Kind of incredible advice, really:
When I started high school my mother told me "Use your best judgment, and remember, nobody likes a prude."
Never leave your house without enough money to get back by yourself. (advice given when I started dating. I view it as a call to independence to this day.)
Tuesday, June 30, 2009
Thursday, June 25, 2009
Tuesday, June 23, 2009
fluent helpers
Fluent C Sharp Language Extension Helpers - Part 1
So, I found myself doing a lot of for( int i = 0; i < n; i++ ){} stuff lately. So, I've decided to try something new. I've started a small collection of "Fluent Helpers" that alleviate a lot of the verbosity in C#.
About 28 characters (including spaces) for a simple for loop to do some constant iteration.
for( int i = 0; i < n, i++){
About 18 characters to do this (no pun intended):
Do.This( 5, () =>{
Here's an example:
Prints:
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Now that feels much better on my hands, and looks much cleaner too, IMHO. Here's the simple implementation for Do.This:
I've already started a little library of these small syntax helpers I've collected. If you have any suggestions, please share! cool0003.gif
-Brian Chavez
So, I found myself doing a lot of for( int i = 0; i < n; i++ ){} stuff lately. So, I've decided to try something new. I've started a small collection of "Fluent Helpers" that alleviate a lot of the verbosity in C#.
About 28 characters (including spaces) for a simple for loop to do some constant iteration.
for( int i = 0; i < n, i++){
About 18 characters to do this (no pun intended):
Do.This( 5, () =>{
Here's an example:
Do.This( 5,() =>
{
Console.Write( "Hello " );
Console.WriteLine( "World!" );
}
);
Prints:
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Now that feels much better on my hands, and looks much cleaner too, IMHO. Here's the simple implementation for Do.This:
public static class Do {
public static void This(int times, Action what)
{
for( int i = 0; i < times; i++ )
what();
}
}
I've already started a little library of these small syntax helpers I've collected. If you have any suggestions, please share! cool0003.gif
-Brian Chavez
Subscribe to:
Posts (Atom)