Hi Jamal,I have tried cs3_fruit.exe and it works when only .net 2 runtime is installed.
Octavian----- Original Message ----- From: "Jamal Mazrui" <empower@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx> Sent: Monday, December 03, 2007 4:56 AM Subject: Re: Minimalist fruit basket program in C# 3.0
Since I had used the C# compiler of the .NET Framework 3.5 SDK, I had assumed that the resulting executable required the .NET Framework 3.5 to run. Evaluating the assembly with the .NET 2.0 PEVerify utility, however, leads me to think that the executable may also run under .NET 2.0. Since I have installed .NET 3.5 on all my computers and it is a large download, I would rather not have to uninstall it to test this hypothesis. Can anyone with .NET 2.0, but not .NET 3.5, download the archive at http://www.EmpowermentZone.com/cs3_fruit.zip and try running the cs3_fruit.exe program? It would be exciting to be able to use C# 3.0 language features without requiring users to install .NET 3.5. Jamal On Wed, 21 Nov 2007, Jamal Mazrui wrote:Date: Wed, 21 Nov 2007 08:42:43 -0500 (EST) From: Jamal Mazrui <empower@xxxxxxxxx> To: programmingblind@xxxxxxxxxxxxx Subject: Minimalist fruit basket program in C# 3.0 From the archive at http://www.EmpowermentZone.com/cs3_fruit.zip This fruit basket program is written in C# 3.0: a language update officially released by Microsoft along with the .NET Framework 3.5 and Visual Studio 2008. Visual C# 2008 Express is a free download that includes the new .NET Framework and SDK. The archive includes a batch file, compile.bat, which invokes the command-line compiler to create an executable, cs3_fruit.exe, which isabout 6K in size. No other files are needed to run the program -- as longas .NET 3.5 is installed.Language enhancements to C# 3.0 include functional and dynamic programmingconstructs, in-line data queries, inferred typing of local variables, and property initialization when calling an object constructor. A technical overview is at http://msdn2.microsoft.com/en-us/library/bb308966.aspx This program uses new language features to be minimalist in the code required to meet the fruit basket specification at http://FruitBasketDemo.AlacornComputer.com No variable types are explicitly declared, each control is specified in asingle statement, and lambda expressions are used for event handlers. Theincluded source code is also pasted below. Jamal /* content of cs3_fruit.cs Fruit Basket program in C# 3.0 Public domain by Jamal Mazrui */ // Import namespaces using System; using System.Windows.Forms; // Define class class FruitBasket { // Define entry point of program static void Main() { // Create controls; var tlp = new TableLayoutPanel {ColumnCount = 3, RowCount = 2}; var lblFruit = new Label {Text = "&Fruit:", Parent = tlp}; var txtFruit = new TextBox {Parent = tlp}; var btnAdd = new Button {Text = "&Add", Parent = tlp}; var lblBasket = new Label {Text = "&Basket:", Parent = tlp}; var lstBasket = new ListBox {Parent = tlp}; var btnDelete = new Button {Text = "&Delete", Parent = tlp}; // Define Add event handler; btnAdd.Click += (o, e) => { var sFruit = txtFruit.Text.Trim(); if (sFruit == "") MessageBox.Show("No fruit to add!", "Alert"); else { lstBasket.Items.Add(sFruit); txtFruit.Clear(); lstBasket.SelectedIndex = lstBasket.Items.Count - 1; } }; // Define Delete event handler; btnDelete.Click += (o,e) => { var iFruit = lstBasket.SelectedIndex; if (iFruit == -1) MessageBox.Show("No fruit to delete!", "Alert"); else { lstBasket.Items.RemoveAt(iFruit); if (iFruit == lstBasket.Items.Count) iFruit--; lstBasket.SelectedIndex = iFruit; } }; // Finalize dialog; var dlg = new Form {Text = "Fruit Basket", AcceptButton = btnAdd, StartPosition = FormStartPosition.CenterScreen, AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink}; dlg.Controls.Add(tlp); // Define closing event handler dlg.Closing += (o, e) => e.Cancel = (MessageBox.Show("Close program?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.No); dlg.ShowDialog(); } // Main method } // FruitBasket class // End of cs3_fruit.cs__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind
__________View the list's information and change your settings at //www.freelists.org/list/programmingblind