[dba-VB] Rectangular Coding Style :)

Salakhetdinov Shamil mcp2004 at mail.ru
Tue Jan 13 06:45:15 CST 2015


Hi All --

Here is an interesting coding exercise.
Source code is borrowed from 
http://codegolf.stackexchange.com/questions/26782/fast-cheap-and-good-choose-any-two .
It didn't work "out-of-the-copy-paste-box" so I have made some corrections:


using System.Windows.Forms;
using System.Linq;class P:
CheckBox{static void Main()
{var p=new Form{Text=
"SELECT ANY TWO"};P[]a=null;
a="FAST CHEAP GOOD".Split().
Select((x,i)=>{var c=new P{
Top=i*50,Text=x};c.Click+=(
s,e) =>{if (a.Count(b=>b.
Checked) >1){a.First(b=>!b.
Checked).Enabled=1<0;}else 
a.All(b=>b.Enabled=0<1);};p.
Controls.Add(c);return c;}).
ToArray();Application.Run(p)
;}}
Enjoy! ;)


-- 
Салахетдинов Шамиль


More information about the dba-VB mailing list