Learn how events are utilized in the .NET Framework Class Library specific to WPF and ASP.NET Web Forms applications. In these examples, we see how C# is generated by the IDE to "wire up" a user action or application event to the code that handles that event.
WPF
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WPFEvents
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
MyButton.Click += MyButton_Click;
MyButton.Click += MyButton_IClickedThis;
}
void MyButton_Click(object sender, RoutedEventArgs e)
{
//throw new NotImplementedException();
MyLabel.Content = "Hello World!";
}
void MyButton_IClickedThis(object sender, RoutedEventArgs e)
{
//throw new NotImplementedException();
MyLabel.Content = "Hello World again!";
}
}
}
ASP.NET
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ASPNETEvents
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MyButton.Click += MyButton_Click;
}
void MyButton_Click(object sender, EventArgs e)
{
//throw new NotImplementedException();
MyLabel.Text = "Hello world!";
}
}
}
Source : MS Virtual Academy
24 December 2011
23 December 2011
C# Lesson 23 : Filtering and Managing Data Collections Using LINQ
In this lesson, we discuss how Structured Query Language provides a means of working with sets of data. Similarly, the LINQ syntax provides a simple way of working with groups of data in generic collections. We demonstrate projecting data onto existing types and new anonymous types.
Before
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnderstandingLINQ
{
class Program
{
static void Main(string[] args)
{
List<Car> myCars = new List<Car>() {
new Car() { Make = "BMW", Model= "550i", Color=CarColor.Blue, StickerPrice=55000, Year=2009},
new Car() { Make="Toyota", Model="4Runner", Color=CarColor.White, StickerPrice=35000, Year=2010},
new Car() { Make="BMW", Model = "745li", Color=CarColor.Black, StickerPrice=75000, Year=2008},
new Car() {Make="Ford", Model="Escape", Color=CarColor.White, StickerPrice=25000, Year=2008},
new Car() {Make="BMW", Model="55i", Color=CarColor.Black, StickerPrice=57000, Year=2010}
};
foreach (var car in myCars)
Console.WriteLine("{0} - {1} - {2}", car.Make, car.Model, car.Year);
Console.ReadLine();
}
}
class Car
{
public string Make { get; set; }
public string Model { get; set; }
public int Year { get; set; }
public double StickerPrice { get; set; }
public CarColor Color { get; set; }
}
enum CarColor
{
White,
Black,
Red,
Blue,
Yellow
}
}
After
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnderstandingLINQ
{
class Program
{
static void Main(string[] args)
{
List<Car> myCars = new List<Car>() {
new Car() { Make = "BMW", Model= "550i", Color=CarColor.Blue, StickerPrice=55000, Year=2009},
new Car() { Make="Toyota", Model="4Runner", Color=CarColor.White, StickerPrice=35000, Year=2010},
new Car() { Make="BMW", Model = "745li", Color=CarColor.Black, StickerPrice=75000, Year=2008},
new Car() {Make="Ford", Model="Escape", Color=CarColor.White, StickerPrice=25000, Year=2008},
new Car() {Make="BMW", Model="55i", Color=CarColor.Black, StickerPrice=57000, Year=2010}
};
/*
var bmws = from car in myCars
where car.Make == "BMW"
&& car.Year == 2010
select new { car.Make, car.Model, car.Year };
*/
/*
var orderedCars = from car in myCars
orderby car.Year descending
select car;
*/
//var _bmws = myCars.Where(p => p.Year == 2010).Where(p => p.Make == "BMW");
//var _orderedCars = myCars.OrderByDescending(p => p.Year);
var sum = myCars.Sum(p => p.StickerPrice);
/*
foreach (var car in _orderedCars)
Console.WriteLine("{0} - {1} - {2}", car.Make, car.Model, car.Year);
*/
Console.WriteLine(sum);
Console.ReadLine();
}
}
class Car
{
public string Make { get; set; }
public string Model { get; set; }
public int Year { get; set; }
public double StickerPrice { get; set; }
public CarColor Color { get; set; }
}
enum CarColor
{
White,
Black,
Red,
Blue,
Yellow
}
}
Source : MS Virtual Academy
Before
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnderstandingLINQ
{
class Program
{
static void Main(string[] args)
{
List<Car> myCars = new List<Car>() {
new Car() { Make = "BMW", Model= "550i", Color=CarColor.Blue, StickerPrice=55000, Year=2009},
new Car() { Make="Toyota", Model="4Runner", Color=CarColor.White, StickerPrice=35000, Year=2010},
new Car() { Make="BMW", Model = "745li", Color=CarColor.Black, StickerPrice=75000, Year=2008},
new Car() {Make="Ford", Model="Escape", Color=CarColor.White, StickerPrice=25000, Year=2008},
new Car() {Make="BMW", Model="55i", Color=CarColor.Black, StickerPrice=57000, Year=2010}
};
foreach (var car in myCars)
Console.WriteLine("{0} - {1} - {2}", car.Make, car.Model, car.Year);
Console.ReadLine();
}
}
class Car
{
public string Make { get; set; }
public string Model { get; set; }
public int Year { get; set; }
public double StickerPrice { get; set; }
public CarColor Color { get; set; }
}
enum CarColor
{
White,
Black,
Red,
Blue,
Yellow
}
}
After
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnderstandingLINQ
{
class Program
{
static void Main(string[] args)
{
List<Car> myCars = new List<Car>() {
new Car() { Make = "BMW", Model= "550i", Color=CarColor.Blue, StickerPrice=55000, Year=2009},
new Car() { Make="Toyota", Model="4Runner", Color=CarColor.White, StickerPrice=35000, Year=2010},
new Car() { Make="BMW", Model = "745li", Color=CarColor.Black, StickerPrice=75000, Year=2008},
new Car() {Make="Ford", Model="Escape", Color=CarColor.White, StickerPrice=25000, Year=2008},
new Car() {Make="BMW", Model="55i", Color=CarColor.Black, StickerPrice=57000, Year=2010}
};
/*
var bmws = from car in myCars
where car.Make == "BMW"
&& car.Year == 2010
select new { car.Make, car.Model, car.Year };
*/
/*
var orderedCars = from car in myCars
orderby car.Year descending
select car;
*/
//var _bmws = myCars.Where(p => p.Year == 2010).Where(p => p.Make == "BMW");
//var _orderedCars = myCars.OrderByDescending(p => p.Year);
var sum = myCars.Sum(p => p.StickerPrice);
/*
foreach (var car in _orderedCars)
Console.WriteLine("{0} - {1} - {2}", car.Make, car.Model, car.Year);
*/
Console.WriteLine(sum);
Console.ReadLine();
}
}
class Car
{
public string Make { get; set; }
public string Model { get; set; }
public int Year { get; set; }
public double StickerPrice { get; set; }
public CarColor Color { get; set; }
}
enum CarColor
{
White,
Black,
Red,
Blue,
Yellow
}
}
Source : MS Virtual Academy
22 December 2011
C# Lesson 22 : Working with Collections
Collections are a more powerful form of arrays. In this lesson, we demonstrate an "old style" collection (pointing out its limitations), along with several of the newer, strongly typed generic collections (List<T> and Dictionary<T1, T2>) utilizing the generics syntax.
Before
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WorkingWithCollections
{
class Program
{
static void Main(string[] args)
{
Car car1 = new Car();
car1.Make = "Oldsmobile";
car1.Model = "Cutlas Supreme";
Car car2 = new Car();
car2.Make = "Geo";
car2.Model = "Prism";
Book b1 = new Book();
b1.Author = "Robert Tabor";
b1.Author = "Microsoft .NET XML Web Services";
b1.ISBN = "0-000-00000-0";
Console.ReadLine();
}
}
class Car
{
public string Make { get; set; }
public string Model { get; set; }
}
class Book
{
public string Title { get; set; }
public string Author { get; set; }
public string ISBN { get; set; }
}
}
After
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WorkingWithCollections
{
class Program
{
static void Main(string[] args)
{
/*
Car car1 = new Car();
car1.Make = "Oldsmobile";
car1.Model = "Cutlas Supreme";
Car car2 = new Car();
car2.Make = "Geo";
car2.Model = "Prism";
Book b1 = new Book();
b1.Author = "Robert Tabor";
b1.Author = "Microsoft .NET XML Web Services";
b1.ISBN = "0-000-00000-0";
*/
// ArrayLists are dynamically sized, and support other
// cool features like sorting, removing items, etc.
/*
System.Collections.ArrayList myArrayList = new System.Collections.ArrayList();
myArrayList.Add(car1);
myArrayList.Add(car2);
myArrayList.Add(b1);
myArrayList.Remove(b1);
foreach (object o in myArrayList)
{
Console.WriteLine(((Car)o).Make);
}
*/
// Dictionaries allow you to save a key along with
// the value, and also support cool features.
// There are different dictionaries to choose from ...
/*
System.Collections.Specialized.ListDictionary myDictionary
= new System.Collections.Specialized.ListDictionary();
myDictionary.Add(car1.Make, car1);
myDictionary.Add(car2.Make, car2);
myDictionary.Add(b1.Author, b1);
// Easy access to an element using its key
Console.WriteLine(((Car)myDictionary["Geo"]).Model);
// But since its not strongly typed, we can easily break it
// by adding a different type to the dictionary ...
// Obviously, I'm trying to retrieve a book here, and then get its ... model?
Console.WriteLine(((Car)myDictionary["Robert Tabor"]).Model);
*/
/*
List<Car> myList = new List<Car>();
myList.Add(car1);
myList.Add(car2);
//myList.Add(b1);
foreach (Car car in myList)
{
// No casting!
Console.WriteLine(car.Model);
}
*/
/*
Dictionary<string, Car> myDictionary = new Dictionary<string, Car>();
myDictionary.Add(car1.Make, car1);
myDictionary.Add(car2.Make, car2);
Console.WriteLine(myDictionary["Geo"].Model);
*/
//string[] names = { "Bob", "Steve", "Brian", "Chuck" };
Car car1 = new Car() { Make = "Oldsmobile", Model = "Cutlas Supreme" };
Car car2 = new Car() { Make = "Geo", Model = "Prism" };
Car car3 = new Car() { Make = "Nissan", Model = "Altima" };
List<Car> myList = new List<Car>() {
new Car { Make = "Oldsmobile", Model = "Cutlas Supreme"},
new Car { Make = "Geo", Model="Prism"},
new Car { Make = "Nissan", Model = "Altima"}
};
Console.ReadLine();
}
}
class Car
{
public string Make { get; set; }
public string Model { get; set; }
}
class Book
{
public string Title { get; set; }
public string Author { get; set; }
public string ISBN { get; set; }
}
}
Source : MS Virtual Academy
Before
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WorkingWithCollections
{
class Program
{
static void Main(string[] args)
{
Car car1 = new Car();
car1.Make = "Oldsmobile";
car1.Model = "Cutlas Supreme";
Car car2 = new Car();
car2.Make = "Geo";
car2.Model = "Prism";
Book b1 = new Book();
b1.Author = "Robert Tabor";
b1.Author = "Microsoft .NET XML Web Services";
b1.ISBN = "0-000-00000-0";
Console.ReadLine();
}
}
class Car
{
public string Make { get; set; }
public string Model { get; set; }
}
class Book
{
public string Title { get; set; }
public string Author { get; set; }
public string ISBN { get; set; }
}
}
After
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WorkingWithCollections
{
class Program
{
static void Main(string[] args)
{
/*
Car car1 = new Car();
car1.Make = "Oldsmobile";
car1.Model = "Cutlas Supreme";
Car car2 = new Car();
car2.Make = "Geo";
car2.Model = "Prism";
Book b1 = new Book();
b1.Author = "Robert Tabor";
b1.Author = "Microsoft .NET XML Web Services";
b1.ISBN = "0-000-00000-0";
*/
// ArrayLists are dynamically sized, and support other
// cool features like sorting, removing items, etc.
/*
System.Collections.ArrayList myArrayList = new System.Collections.ArrayList();
myArrayList.Add(car1);
myArrayList.Add(car2);
myArrayList.Add(b1);
myArrayList.Remove(b1);
foreach (object o in myArrayList)
{
Console.WriteLine(((Car)o).Make);
}
*/
// Dictionaries allow you to save a key along with
// the value, and also support cool features.
// There are different dictionaries to choose from ...
/*
System.Collections.Specialized.ListDictionary myDictionary
= new System.Collections.Specialized.ListDictionary();
myDictionary.Add(car1.Make, car1);
myDictionary.Add(car2.Make, car2);
myDictionary.Add(b1.Author, b1);
// Easy access to an element using its key
Console.WriteLine(((Car)myDictionary["Geo"]).Model);
// But since its not strongly typed, we can easily break it
// by adding a different type to the dictionary ...
// Obviously, I'm trying to retrieve a book here, and then get its ... model?
Console.WriteLine(((Car)myDictionary["Robert Tabor"]).Model);
*/
/*
List<Car> myList = new List<Car>();
myList.Add(car1);
myList.Add(car2);
//myList.Add(b1);
foreach (Car car in myList)
{
// No casting!
Console.WriteLine(car.Model);
}
*/
/*
Dictionary<string, Car> myDictionary = new Dictionary<string, Car>();
myDictionary.Add(car1.Make, car1);
myDictionary.Add(car2.Make, car2);
Console.WriteLine(myDictionary["Geo"].Model);
*/
//string[] names = { "Bob", "Steve", "Brian", "Chuck" };
Car car1 = new Car() { Make = "Oldsmobile", Model = "Cutlas Supreme" };
Car car2 = new Car() { Make = "Geo", Model = "Prism" };
Car car3 = new Car() { Make = "Nissan", Model = "Altima" };
List<Car> myList = new List<Car>() {
new Car { Make = "Oldsmobile", Model = "Cutlas Supreme"},
new Car { Make = "Geo", Model="Prism"},
new Car { Make = "Nissan", Model = "Altima"}
};
Console.ReadLine();
}
}
class Car
{
public string Make { get; set; }
public string Model { get; set; }
}
class Book
{
public string Title { get; set; }
public string Author { get; set; }
public string ISBN { get; set; }
}
}
Source : MS Virtual Academy
21 December 2011
C# Lesson 21 : Gracefully Handling Exceptions
Exceptions occur when an application experiences some unexpected problem at run time. This lesson discusses how to use the try catch finally block to anticipate potential problems and to attempt to shield the end user from those problems as much as possible. We also explore best practices when checking for exceptions.
Before
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ReadTextFileWhile
{
class Program
{
static void Main(string[] args)
{
StreamReader myReader = new StreamReader("Values.txt");
string line = "";
while (line != null)
{
line = myReader.ReadLine();
if (line != null)
Console.WriteLine(line);
}
myReader.Close();
Console.ReadLine();
}
}
}
After
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ReadTextFileWhile
{
class Program
{
static void Main(string[] args)
{
try
{
StreamReader myReader = new StreamReader("Values.txt");
string line = "";
while (line != null)
{
line = myReader.ReadLine();
if (line != null)
Console.WriteLine(line);
}
myReader.Close();
}
catch (DirectoryNotFoundException e)
{
Console.WriteLine("Couldn't fine the file. Are you sure the DIRECTORY exists?");
}
catch (FileNotFoundException e)
{
Console.WriteLine("Couldn't find the file. Are you sure you're looking for the correct file?");
}
catch (Exception e)
{
Console.WriteLine("Something didn't quite work correctly: {0}", e.Message);
}
finally
{
// Perform any cleanup to roll back the data or close connections
// to files, database, network, etc.
}
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
Before
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ReadTextFileWhile
{
class Program
{
static void Main(string[] args)
{
StreamReader myReader = new StreamReader("Values.txt");
string line = "";
while (line != null)
{
line = myReader.ReadLine();
if (line != null)
Console.WriteLine(line);
}
myReader.Close();
Console.ReadLine();
}
}
}
After
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ReadTextFileWhile
{
class Program
{
static void Main(string[] args)
{
try
{
StreamReader myReader = new StreamReader("Values.txt");
string line = "";
while (line != null)
{
line = myReader.ReadLine();
if (line != null)
Console.WriteLine(line);
}
myReader.Close();
}
catch (DirectoryNotFoundException e)
{
Console.WriteLine("Couldn't fine the file. Are you sure the DIRECTORY exists?");
}
catch (FileNotFoundException e)
{
Console.WriteLine("Couldn't find the file. Are you sure you're looking for the correct file?");
}
catch (Exception e)
{
Console.WriteLine("Something didn't quite work correctly: {0}", e.Message);
}
finally
{
// Perform any cleanup to roll back the data or close connections
// to files, database, network, etc.
}
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
20 December 2011
C# Lesson 20 : Enumerations and the switch Decision Statement
Here, we demonstrate the use of Enumerations because, in the .NET Framework Class Library, properties can often be set only to a predetermined subset of possible values. To illustrate this point, we create our own custom enumeration and then utilize it in a simple application that demonstrates a third Decision statement, the switch.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UsingSwitch
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Type in a super hero's name to see his nickname:");
string userValue = Console.ReadLine();
switch(userValue.ToUpper())
{
case "BATMAN":
Console.WriteLine("Caped Crusader");
break;
case "SUPERMAN":
Console.WriteLine("Man of Steel");
break;
case "GREENLANTERN":
Console.WriteLine("Emerald Knight");
break;
default:
Console.WriteLine("Does not compute");
break;
}
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnderstandingEnumerations
{
class Program
{
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.DarkRed;
//Console.WriteLine("Hello world!");
Console.WriteLine("Type in a superhero's name to see his nickname: ");
string userValue = Console.ReadLine();
SuperHero myValue;
if (Enum.TryParse<SuperHero>(userValue, true, out myValue))
{
switch (myValue)
{
case SuperHero.Batman:
Console.WriteLine("Caped crusader");
break;
case SuperHero.Superman:
Console.WriteLine("Man of Steel");
break;
case SuperHero.GreenLantern:
Console.WriteLine("Emerald Knight");
break;
default:
break;
}
}
else
{
Console.WriteLine("Does not compute");
}
Console.ReadLine();
}
}
enum SuperHero
{
Batman,
Superman,
GreenLantern
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComplexIfStatement
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Pick a number between 1 and 100:");
string userValue = Console.ReadLine();
int compareValue = int.Parse(userValue);
if ((compareValue < 1) || (compareValue > 100))
Console.WriteLine("The number you chose was out of bounds.");
else if ((compareValue == 42) || (compareValue > 90))
Console.WriteLine("You found one of the special numbers!");
else
Console.WriteLine("You didn't find one of the special numbers");
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UsingSwitch
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Type in a super hero's name to see his nickname:");
string userValue = Console.ReadLine();
switch(userValue.ToUpper())
{
case "BATMAN":
Console.WriteLine("Caped Crusader");
break;
case "SUPERMAN":
Console.WriteLine("Man of Steel");
break;
case "GREENLANTERN":
Console.WriteLine("Emerald Knight");
break;
default:
Console.WriteLine("Does not compute");
break;
}
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnderstandingEnumerations
{
class Program
{
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.DarkRed;
//Console.WriteLine("Hello world!");
Console.WriteLine("Type in a superhero's name to see his nickname: ");
string userValue = Console.ReadLine();
SuperHero myValue;
if (Enum.TryParse<SuperHero>(userValue, true, out myValue))
{
switch (myValue)
{
case SuperHero.Batman:
Console.WriteLine("Caped crusader");
break;
case SuperHero.Superman:
Console.WriteLine("Man of Steel");
break;
case SuperHero.GreenLantern:
Console.WriteLine("Emerald Knight");
break;
default:
break;
}
}
else
{
Console.WriteLine("Does not compute");
}
Console.ReadLine();
}
}
enum SuperHero
{
Batman,
Superman,
GreenLantern
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComplexIfStatement
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Pick a number between 1 and 100:");
string userValue = Console.ReadLine();
int compareValue = int.Parse(userValue);
if ((compareValue < 1) || (compareValue > 100))
Console.WriteLine("The number you chose was out of bounds.");
else if ((compareValue == 42) || (compareValue > 90))
Console.WriteLine("You found one of the special numbers!");
else
Console.WriteLine("You didn't find one of the special numbers");
Console.ReadLine();
}
}
}
19 December 2011
C# Lesson 19 : Understanding Scope and Utilizing Accessibility Modifiers
Explore the scope of variables within code blocks and how accessibility modifiers, such as Public, Private, and Protected, are used by the .NET Framework Class Library to expose or hide implementation of their given services to consumers of that given class. This is sometimes referred to as "encapsulation."
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnderstandingScope
{
class Program
{
// private static string k = "";
static void Main(string[] args)
{
/*
string j = "";
for (int i = 0; i < 10; i++)
{
j = i.ToString();
k = i.ToString();
Console.WriteLine(i);
if (i == 9)
{
string l = i.ToString();
}
//Console.WriteLine("l: " + l);
}
//Console.WriteLine(i);
Console.WriteLine("Outsite of the for: " + j);
//Console.WriteLine("k: " + k);
helperMethod();
*/
Car car = new Car();
car.DoSomething();
Console.ReadLine();
}
/*
static void helperMethod()
{
Console.WriteLine("k from the helperMethod: " + k);
}
*/
}
class Car
{
public void DoSomething()
{
Console.WriteLine(helperMethod());
}
private string helperMethod()
{
return "Hello world!";
}
}
}
Source : MS Virtual Academy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnderstandingScope
{
class Program
{
// private static string k = "";
static void Main(string[] args)
{
/*
string j = "";
for (int i = 0; i < 10; i++)
{
j = i.ToString();
k = i.ToString();
Console.WriteLine(i);
if (i == 9)
{
string l = i.ToString();
}
//Console.WriteLine("l: " + l);
}
//Console.WriteLine(i);
Console.WriteLine("Outsite of the for: " + j);
//Console.WriteLine("k: " + k);
helperMethod();
*/
Car car = new Car();
car.DoSomething();
Console.ReadLine();
}
/*
static void helperMethod()
{
Console.WriteLine("k from the helperMethod: " + k);
}
*/
}
class Car
{
public void DoSomething()
{
Console.WriteLine(helperMethod());
}
private string helperMethod()
{
return "Hello world!";
}
}
}
Source : MS Virtual Academy
18 December 2011
C# Lesson 18 : Understanding Namespaces and Adding References to Assemblies
In this lesson, we explain how Namespaces allow us to disambiguate classes that may share the same name. And we explain how the .NET Framework Class Library is so large that including all its classes in every application you write is a waste of system resources. Certain project templates include references to the typical assemblies required by a given type of application, and we demonstrate this by referencing a custom assembly of Bob's own design.
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tabor;
namespace NamespacesAndReferencingAssemblies
{
class Program
{
static void Main(string[] args)
{
//System.IO.StreamReader myStreamReader = new System.IO.StreamReader();
//StreamReader myStreamReader = new StreamReader();
Bob bob = new Bob();
string html = bob.Lookup("http://www.learnvisualstudio.net");
Console.WriteLine(html);
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tabor;
namespace NamespacesAndReferencingAssemblies
{
class Program
{
static void Main(string[] args)
{
//System.IO.StreamReader myStreamReader = new System.IO.StreamReader();
//StreamReader myStreamReader = new StreamReader();
Bob bob = new Bob();
string html = bob.Lookup("http://www.learnvisualstudio.net");
Console.WriteLine(html);
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
17 December 2011
C# Lesson 17 : Working with Classes and Inheritances in the .NET Framework Class Library
This lesson continues to teach concepts about classes (specifically, in this case, inheritance) by showing you how to utilize inheritance in your own custom classes. Learn about overriding virtual functionality, abstract base classes, and sealed classes.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnderstandingInheritance
{
class Program
{
static void Main(string[] args)
{
Car myCar = new Car();
myCar.Make = "BMW";
myCar.Model = "745li";
myCar.Color = "Black";
myCar.Year = 2005;
//myCar.TowingCapacity = 1200;
printVehicleDetails(myCar);
Truck myTruck = new Truck();
myTruck.Make = "Ford";
myTruck.Model = "F950";
myTruck.Year = 2006;
myTruck.Color = "Black";
myTruck.TowingCapacity = 1200;
printVehicleDetails(myTruck);
Console.ReadLine();
}
private static void printVehicleDetails(Vehicle vehicle)
{
Console.WriteLine("Here are the vehcile's details: {0}",
vehicle.FormatMe());
}
}
abstract class Vehicle
{
public string Make { get; set; }
public string Model { get; set; }
public int Year { get; set; }
public string Color { get; set; }
public abstract string FormatMe();
}
class Car : Vehicle
{
public override string FormatMe()
{
return String.Format("{0} - {1} - {2} - {3}",
this.Make,
this.Model,
this.Color,
this.Year);
}
}
sealed class Truck : Vehicle
{
public int TowingCapacity { get; set; }
public override string FormatMe()
{
return String.Format("{0} - {1} - {2} Towing units",
this.Make,
this.Model,
this.TowingCapacity);
}
}
/*
class Semi : Truck
{
}
*/
}
Source : MS Virtual Academy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnderstandingInheritance
{
class Program
{
static void Main(string[] args)
{
Car myCar = new Car();
myCar.Make = "BMW";
myCar.Model = "745li";
myCar.Color = "Black";
myCar.Year = 2005;
//myCar.TowingCapacity = 1200;
printVehicleDetails(myCar);
Truck myTruck = new Truck();
myTruck.Make = "Ford";
myTruck.Model = "F950";
myTruck.Year = 2006;
myTruck.Color = "Black";
myTruck.TowingCapacity = 1200;
printVehicleDetails(myTruck);
Console.ReadLine();
}
private static void printVehicleDetails(Vehicle vehicle)
{
Console.WriteLine("Here are the vehcile's details: {0}",
vehicle.FormatMe());
}
}
abstract class Vehicle
{
public string Make { get; set; }
public string Model { get; set; }
public int Year { get; set; }
public string Color { get; set; }
public abstract string FormatMe();
}
class Car : Vehicle
{
public override string FormatMe()
{
return String.Format("{0} - {1} - {2} - {3}",
this.Make,
this.Model,
this.Color,
this.Year);
}
}
sealed class Truck : Vehicle
{
public int TowingCapacity { get; set; }
public override string FormatMe()
{
return String.Format("{0} - {1} - {2} Towing units",
this.Make,
this.Model,
this.TowingCapacity);
}
}
/*
class Semi : Truck
{
}
*/
}
Source : MS Virtual Academy
16 December 2011
C# Lesson 16 : More About Classes and Methods
This lesson digs into more details about classes—what exactly happens when you create a new instance of a class? What is a reference to an instance of a class? How does passing the reference to a method affect a class? We also review overloaded methods, static versus instance methods, and constructors.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ObjectLifetime
{
class Program
{
static void Main(string[] args)
{
Car myCar = new Car();
// set properties
Car myOtherCar = myCar;
Car myThirdCar = new Car("Ford", "Escape", 2005, "White");
myOtherCar = null;
myCar = null;
}
}
class Car
{
public string Make { get; set; }
public string Model { get; set; }
public int Year { get; set; }
public string Color { get; set; }
public double OriginalPrice { get; set; }
public Car()
{
// You could this from a configuration file, a database, etc.
// I'll just hardcode in this instance.
this.Make = "Nissan";
}
public Car(string make, string model, int year, string color)
{
Make = make;
Model = model;
Year = year;
Color = color;
}
/*
public Car(string someOtherInputParameter, string model, int year, string color)
{
Make = someOtherInputParameter;
Model = model;
Year = year;
Color = color;
}
* */
public static void MyMethod()
{
}
}
}
Source : MS Virtual Academy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ObjectLifetime
{
class Program
{
static void Main(string[] args)
{
Car myCar = new Car();
// set properties
Car myOtherCar = myCar;
Car myThirdCar = new Car("Ford", "Escape", 2005, "White");
myOtherCar = null;
myCar = null;
}
}
class Car
{
public string Make { get; set; }
public string Model { get; set; }
public int Year { get; set; }
public string Color { get; set; }
public double OriginalPrice { get; set; }
public Car()
{
// You could this from a configuration file, a database, etc.
// I'll just hardcode in this instance.
this.Make = "Nissan";
}
public Car(string make, string model, int year, string color)
{
Make = make;
Model = model;
Year = year;
Color = color;
}
/*
public Car(string someOtherInputParameter, string model, int year, string color)
{
Make = someOtherInputParameter;
Model = model;
Year = year;
Color = color;
}
* */
public static void MyMethod()
{
}
}
}
Source : MS Virtual Academy
15 December 2011
C# Lesson 15 : Understanding and Creating Classes
Classes are integral to the .NET Framework, particularly the .NET Framework Class Library. Learn how classes are defined and new instances are created, how to define Properties, and how to both set values and get values for a given instance of the class.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SimpleClasses
{
class Program
{
static void Main(string[] args)
{
Car myNewCar = new Car();
myNewCar.Make = "Oldsmobile";
myNewCar.Model = "Cutlas Supreme";
myNewCar.Year = 1986;
myNewCar.Color = "Silver";
Console.WriteLine("{0} - {1} - {2}",
myNewCar.Make,
myNewCar.Model,
myNewCar.Color);
//double marketValueOfCar = determineMarketValue(myNewCar);
Console.WriteLine("Car's value: {0:C}", myNewCar.DetermineMarketValue());
Console.ReadLine();
}
private static double determineMarketValue(Car _car)
{
double carValue = 100.0;
// Somedat white come to go online and look up the car's value
// and trieve its value into the carValue variable
return carValue;
}
}
class Car
{
public string Make { get; set; }
public string Model { get; set; }
public int Year { get; set; }
public string Color { get; set; }
public double DetermineMarketValue()
{
double carValue = 100.0;
if (this.Year > 1990)
carValue = 10000.0;
else
carValue = 2000.0;
return carValue;
}
}
}
Source : MS Virtual Academy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SimpleClasses
{
class Program
{
static void Main(string[] args)
{
Car myNewCar = new Car();
myNewCar.Make = "Oldsmobile";
myNewCar.Model = "Cutlas Supreme";
myNewCar.Year = 1986;
myNewCar.Color = "Silver";
Console.WriteLine("{0} - {1} - {2}",
myNewCar.Make,
myNewCar.Model,
myNewCar.Color);
//double marketValueOfCar = determineMarketValue(myNewCar);
Console.WriteLine("Car's value: {0:C}", myNewCar.DetermineMarketValue());
Console.ReadLine();
}
private static double determineMarketValue(Car _car)
{
double carValue = 100.0;
// Somedat white come to go online and look up the car's value
// and trieve its value into the carValue variable
return carValue;
}
}
class Car
{
public string Make { get; set; }
public string Model { get; set; }
public int Year { get; set; }
public string Color { get; set; }
public double DetermineMarketValue()
{
double carValue = 100.0;
if (this.Year > 1990)
carValue = 10000.0;
else
carValue = 2000.0;
return carValue;
}
}
}
Source : MS Virtual Academy
14 December 2011
C# Lesson 14 : Working with DateTime
Like strings, dates and times are represented using special types and so deserve some attention. In this lesson, we learn how to work with Date and Time data, how to create new instances of DateTime, how to add time, and how to format the data for display. We also discuss the TimeSpan class.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatesAndTimes
{
class Program
{
static void Main(string[] args)
{
DateTime myValue = DateTime.Now;
//Console.WriteLine(myValue.ToString());
//Console.WriteLine(myValue.ToShortDateString());
//Console.WriteLine(myValue.ToShortTimeString());
//Console.WriteLine(myValue.ToLongDateString());
//Console.WriteLine(myValue.ToLongTimeString());
//Console.WriteLine(myValue.AddDays(3).ToLongDateString());
//Console.WriteLine(myValue.AddHours(3).ToShortTimeString());
//Console.WriteLine(myValue.AddDays(-3).ToShortDateString());
//Console.WriteLine(myValue.Month.ToString());
//DateTime myBirthday = new DateTime(1969, 12, 7);
//Console.WriteLine(myBirthday.ToShortDateString());
DateTime myBirthday = DateTime.Parse("12/7/1969");
TimeSpan myAge = DateTime.Now.Subtract(myBirthday);
Console.WriteLine(myAge.TotalDays);
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatesAndTimes
{
class Program
{
static void Main(string[] args)
{
DateTime myValue = DateTime.Now;
//Console.WriteLine(myValue.ToString());
//Console.WriteLine(myValue.ToShortDateString());
//Console.WriteLine(myValue.ToShortTimeString());
//Console.WriteLine(myValue.ToLongDateString());
//Console.WriteLine(myValue.ToLongTimeString());
//Console.WriteLine(myValue.AddDays(3).ToLongDateString());
//Console.WriteLine(myValue.AddHours(3).ToShortTimeString());
//Console.WriteLine(myValue.AddDays(-3).ToShortDateString());
//Console.WriteLine(myValue.Month.ToString());
//DateTime myBirthday = new DateTime(1969, 12, 7);
//Console.WriteLine(myBirthday.ToShortDateString());
DateTime myBirthday = DateTime.Parse("12/7/1969");
TimeSpan myAge = DateTime.Now.Subtract(myBirthday);
Console.WriteLine(myAge.TotalDays);
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
13 December 2011
C# Lesson 13 : Working with Strings
Since oftentimes in our applications we'll want to work with string data, this lesson approaches a number of different string manipulations. We look at built-in String methods to manipulate the content inside of a literal string and at the StringBuilder class for concatenating many strings together in a memory and resource-friendly manner.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Strings
{
class Program
{
static void Main(string[] args)
{
//string myString = "Go to your c:\\ drive";
//string myString = "My \"so called\" life";
//string myString = "What if I need \n a new line?";
//string myString = string.Format("{0}!", "Bonzai");
//string myString = string.Format("Make: {0} (Model: {1})", "BMW", "760li");
//string myString = string.Format("{0:C}", 123.45);
//string myString = string.Format("{0:N}", 123456789);
//string myString = string.Format("{0:P}", .123);
//string myString = string.Format("Phone number: {0:(###) ###-####}", 1234567890);
/*
string myString = "";
for (int i = 0; i < 100; i++)
{
//myString = myString + "--" + i.ToString();
myString += "--" + i.ToString();
}
* */
/*
StringBuilder myString = new StringBuilder();
for (int i = 0; i < 100; i++)
{
myString.Append("--");
myString.Append(i);
}
*/
string myString = " That summer we took threes across the board ";
//myString = myString.Substring(5, 14);
//myString = myString.ToUpper();
//myString = myString.Replace(" ", "--");
myString = String.Format("Length before: {0} -- After: {1}",
myString.Length, myString.Trim().Length);
Console.WriteLine(myString);
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Strings
{
class Program
{
static void Main(string[] args)
{
//string myString = "Go to your c:\\ drive";
//string myString = "My \"so called\" life";
//string myString = "What if I need \n a new line?";
//string myString = string.Format("{0}!", "Bonzai");
//string myString = string.Format("Make: {0} (Model: {1})", "BMW", "760li");
//string myString = string.Format("{0:C}", 123.45);
//string myString = string.Format("{0:N}", 123456789);
//string myString = string.Format("{0:P}", .123);
//string myString = string.Format("Phone number: {0:(###) ###-####}", 1234567890);
/*
string myString = "";
for (int i = 0; i < 100; i++)
{
//myString = myString + "--" + i.ToString();
myString += "--" + i.ToString();
}
* */
/*
StringBuilder myString = new StringBuilder();
for (int i = 0; i < 100; i++)
{
myString.Append("--");
myString.Append(i);
}
*/
string myString = " That summer we took threes across the board ";
//myString = myString.Substring(5, 14);
//myString = myString.ToUpper();
//myString = myString.Replace(" ", "--");
myString = String.Format("Length before: {0} -- After: {1}",
myString.Length, myString.Trim().Length);
Console.WriteLine(myString);
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
12 December 2011
C# Lesson 12 : While Iterations and Reading Data from a Text File
Learn a new type of iteration statement (while) and how to utilize the StreamReader class to stream data from a file to the Console window. Additionally, we learn how to add new files to our project, how to set properties of our file using the Properties window, and how to add a using statement as a means of resolving a class name referenced in our code to the namespace in which it is defined.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ReadTextFileWhile
{
class Program
{
static void Main(string[] args)
{
StreamReader myReader = new StreamReader("Values.txt");
string line = "";
while (line != null)
{
line = myReader.ReadLine();
if (line != null)
Console.WriteLine(line);
}
myReader.Close();
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ReadTextFileWhile
{
class Program
{
static void Main(string[] args)
{
StreamReader myReader = new StreamReader("Values.txt");
string line = "";
while (line != null)
{
line = myReader.ReadLine();
if (line != null)
Console.WriteLine(line);
}
myReader.Close();
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
11 December 2011
C# Lesson 11 : Creating and Calling Simple Overloaded Helper Methods
Now, we begin wading into the topic of methods by creating a helper method to break out code we may need to use in multiple places within our code. We create and call our methods to retrieve a value, create and use input parameters, learn about string formatting, and create overloaded versions of our method.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HelperMethods
{
class Program
{
static void Main(string[] args)
{
//string myValue = superSecretFormula("world");
string myValue = superSecretFormula("sunshine");
Console.WriteLine(myValue);
Console.ReadLine();
}
private static string superSecretFormula()
{
// some cool stuff here
return "Hello World!";
}
private static string superSecretFormula(string name)
{
return String.Format("Hello, {0}!", name);
}
}
}
Source : MS Virtual Academy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HelperMethods
{
class Program
{
static void Main(string[] args)
{
//string myValue = superSecretFormula("world");
string myValue = superSecretFormula("sunshine");
Console.WriteLine(myValue);
Console.ReadLine();
}
private static string superSecretFormula()
{
// some cool stuff here
return "Hello World!";
}
private static string superSecretFormula(string name)
{
return String.Format("Hello, {0}!", name);
}
}
}
Source : MS Virtual Academy
10 December 2011
C# Lesson 10 : Creating Arrays of Values
In this lesson, we talk about arrays, which are multi-part variables—a "bucket" containing other "buckets," if you will. We demonstrate how to declare and utilize arrays, and we demonstrate a couple of powerful built-in methods that give arrays added features.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnderstandingArrays
{
class Program
{
static void Main(string[] args)
{
int[] numbers = new int[5];
numbers[0] = 4;
numbers[1] = 8;
numbers[2] = 15;
numbers[3] = 16;
numbers[4] = 23;
//numbers[5] = 42;
Console.WriteLine(numbers.Length);
/*
int[] numbers = new int[] { 4, 8, 15, 16, 23, 42 };
Console.WriteLine(numbers[1].ToString());
Console.ReadLine();
*/
/*
string[] names = new string[] { "Eddie", "Alex", "Michael", "David Lee" };
foreach (string name in names)
{
Console.WriteLine(name);
}
Console.ReadLine();
*/
/*
string zig = "You can get what you want out of life " +
"if you help enough other people get what they want.";
char[] charArray = zig.ToCharArray();
Array.Reverse(charArray);
foreach (char zigChar in charArray)
Console.Write(zigChar);
*/
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnderstandingArrays
{
class Program
{
static void Main(string[] args)
{
int[] numbers = new int[5];
numbers[0] = 4;
numbers[1] = 8;
numbers[2] = 15;
numbers[3] = 16;
numbers[4] = 23;
//numbers[5] = 42;
Console.WriteLine(numbers.Length);
/*
int[] numbers = new int[] { 4, 8, 15, 16, 23, 42 };
Console.WriteLine(numbers[1].ToString());
Console.ReadLine();
*/
/*
string[] names = new string[] { "Eddie", "Alex", "Michael", "David Lee" };
foreach (string name in names)
{
Console.WriteLine(name);
}
Console.ReadLine();
*/
/*
string zig = "You can get what you want out of life " +
"if you help enough other people get what they want.";
char[] charArray = zig.ToCharArray();
Array.Reverse(charArray);
foreach (char zigChar in charArray)
Console.Write(zigChar);
*/
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
09 December 2011
C# Lesson 9 : For Iterations
Iterations allow our applications to loop through a block of code until a condition is satisfied. We cover several different types of iteration statements throughout this series, how to utilize "code snippets" to help remind you of the syntax for this complex statement, and debugging in action.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ForIterations
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 10; i++)
{
//Console.WriteLine(i.ToString());
if (i == 7)
{
Console.WriteLine("Found seven!");
break;
}
}
for (int myValue = 0; myValue < 12; myValue++)
{
Console.WriteLine(myValue);
}
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ForIterations
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 10; i++)
{
//Console.WriteLine(i.ToString());
if (i == 7)
{
Console.WriteLine("Found seven!");
break;
}
}
for (int myValue = 0; myValue < 12; myValue++)
{
Console.WriteLine(myValue);
}
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
08 December 2011
C# Lesson 8 : Operators, Expressions, and Statements Duration
In this lesson, we discuss how to create a properly formed C# statement. We discuss how statements are made up of expressions and how expressions are made up of operators (think: verbs) and operands (think: nouns). Finally, we talk about compilation errors that occur when the syntax rules of C# are ignored.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OperatorsExpressionsStatements
{
class Program
{
static void Main(string[] args)
{
int x, y, a, b;
// Assignment operator
x = 3;
y = 2;
a = 1;
b = 0;
// There are many mathematical operators ...
// Addition operator
x = 3 + 4;
// Subtraction operator
x = 4 - 3;
// Multiplication operator
x = 10 * 5;
// Division operator
x = 10 / 5;
// There are many operators used to evaluate values ...
// Equality operator
if (x == y)
{
}
// Greater than operator
if (x > y)
{
}
// Less than operator
if (x < y)
{
}
// Greater or equal to operator
if (x >= y)
{
}
// Less than or equal to operator
if (x <= y)
{
}
// There are two "conditional" operators as well that can be used to expand / enhance an evaluation ...
// ... and they can be combined together multiple times.
// Conditional AND operator …
if ((x > y) && (a > b))
{
}
// Conditional OR operator …
if ((x > y) || (a > b))
{
}
// Also, here's the in-line conditional operator we learned about in the previous lesson ...
string message = (x == 1) ? "Car" : "Boat";
// Member access and Method invocation
Console.WriteLine("Hi");
x + y;
}
}
}
Source : MS Virtual Academy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OperatorsExpressionsStatements
{
class Program
{
static void Main(string[] args)
{
int x, y, a, b;
// Assignment operator
x = 3;
y = 2;
a = 1;
b = 0;
// There are many mathematical operators ...
// Addition operator
x = 3 + 4;
// Subtraction operator
x = 4 - 3;
// Multiplication operator
x = 10 * 5;
// Division operator
x = 10 / 5;
// There are many operators used to evaluate values ...
// Equality operator
if (x == y)
{
}
// Greater than operator
if (x > y)
{
}
// Less than operator
if (x < y)
{
}
// Greater or equal to operator
if (x >= y)
{
}
// Less than or equal to operator
if (x <= y)
{
}
// There are two "conditional" operators as well that can be used to expand / enhance an evaluation ...
// ... and they can be combined together multiple times.
// Conditional AND operator …
if ((x > y) && (a > b))
{
}
// Conditional OR operator …
if ((x > y) || (a > b))
{
}
// Also, here's the in-line conditional operator we learned about in the previous lesson ...
string message = (x == 1) ? "Car" : "Boat";
// Member access and Method invocation
Console.WriteLine("Hi");
x + y;
}
}
}
Source : MS Virtual Academy
07 December 2011
C# Lesson 7 : Branching with the if Decision Statement and the Conditional Operator
Branching allows us to add logic to our applications. This lesson introduces the ‘if Decision’ statement (in its various forms), along with the conditional operator. We also discuss how to refactor our code to make it more compact and less likely to produce errors, by eliminating duplicate code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Decisions
{
class Program
{
static void Main(string[] args)
{
//Console.WriteLine("Please type something and press the Enter key.");
//string userValue;
//userValue = Console.ReadLine();
//Console.WriteLine("You typed: " + userValue);
Console.WriteLine("Would you prefer what is behind door number 1, 2, or 3?");
string userValue = Console.ReadLine();
//string message = "";
//if (userValue == "1")
//{
// message = "You won a new car!";
//}
//else if (userValue == "2")
// message = "You won a new boat!";
//else if (userValue == "3")
// message = "You won a new cat!";
//else
// message = "Sorry, we didn't understand. You lose!";
//Console.WriteLine(message);
string message = (userValue == "1") ? "boat" : "strand of lint";
Console.WriteLine("You won a {0}", message);
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Decisions
{
class Program
{
static void Main(string[] args)
{
//Console.WriteLine("Please type something and press the Enter key.");
//string userValue;
//userValue = Console.ReadLine();
//Console.WriteLine("You typed: " + userValue);
Console.WriteLine("Would you prefer what is behind door number 1, 2, or 3?");
string userValue = Console.ReadLine();
//string message = "";
//if (userValue == "1")
//{
// message = "You won a new car!";
//}
//else if (userValue == "2")
// message = "You won a new boat!";
//else if (userValue == "3")
// message = "You won a new cat!";
//else
// message = "Sorry, we didn't understand. You lose!";
//Console.WriteLine(message);
string message = (userValue == "1") ? "boat" : "strand of lint";
Console.WriteLine("You won a {0}", message);
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
06 December 2011
C# Lesson 6 : Declaring Variables and Assigning Values Duration
Here, we start adding C# syntax to your vocabulary by talking about fundamental building blocks: data types and variables. We also discuss basic topics, such as naming conventions and data type conversions.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Variables
{
class Program
{
static void Main(string[] args)
{
/*
int x;
int y;
x = 7;
y = x + 3;
Console.WriteLine(y);
*/
//string myFirstName;
//myFirstName = "Bob";
//string myFirstNane = "Bob";
//var myFirstName = "Bob";
//var myFirstName = "";
//string myfirstname;
//Console.WriteLine(myFirstName);
int x = 7;
//string y = "Bob";
string y = "5";
string myFirstTry = x.ToString() + y;
//int mySecondTry = x + y;
int mySecondTry = x + int.Parse(y);
Console.WriteLine(myFirstTry);
//Console.WriteLine(mySecondTry);
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Variables
{
class Program
{
static void Main(string[] args)
{
/*
int x;
int y;
x = 7;
y = x + 3;
Console.WriteLine(y);
*/
//string myFirstName;
//myFirstName = "Bob";
//string myFirstNane = "Bob";
//var myFirstName = "Bob";
//var myFirstName = "";
//string myfirstname;
//Console.WriteLine(myFirstName);
int x = 7;
//string y = "Bob";
string y = "5";
string myFirstTry = x.ToString() + y;
//int mySecondTry = x + y;
int mySecondTry = x + int.Parse(y);
Console.WriteLine(myFirstTry);
//Console.WriteLine(mySecondTry);
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
03 December 2011
C# Lesson 3 : Creating Your First C# Program
This lesson teaches you how to create a simple application—first using Windows Notepad and the C# Command Line Compiler, and then by using Visual Studio or Visual C# Express Edition. The video concludes with an explanation of common solutions to the many different problems you might encounter as you first begin writing and compiling code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
// This is a comment
Console.WriteLine("Hello World");
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
// This is a comment
Console.WriteLine("Hello World");
Console.ReadLine();
}
}
}
Source : MS Virtual Academy
23 September 2011
Oracle JDK 7 on OpenSuse as default JVM
After install of jdk-7-linux-i586.rpm, in terminal type these commands:
update-alternatives --install /usr/bin/java java /usr/java/jdk1.7.0/jre/bin/java 20000
update-alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.7.0/jre/bin/javaws 20000
update-alternatives --install /usr/bin/javac javac /usr/java/jdk1.7.0/bin/javac 20000
update-alternatives --install /usr/bin/jar jar /usr/java/jdk1.7.0/bin/jar 20000
update-alternatives --config java
OpenSuse 64
cd /usr/lib64/browser-plugins
ln -s /usr/java/jdk1.7.0/jre/lib/amd64/libnpjp2.so /usr/lib64/browser-plugins/libnpjp2.so
FoxPro 64bit plugin
update-alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/jdk1.7.0/jre/lib/amd64/libnpjp2.so 20000
FoxPro 32bit plugin
update-alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jdk1.7.0/jre/lib/i386/libnpjp2.so 20000
22 September 2011
JasperReport in NetBeans Swing Desktop Application
This is finally successfully coded procedure for showing Jasper Report in NetBeans Swing Desktop Application :
public void ShowReport() {
try {
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/neosoft", "postgres", "postgres");
HashMap hm = new HashMap();
JasperReport jre;
jre = JasperCompileManager.compileReport("src//japi//report1.jrxml");
JasperPrint jr = JasperFillManager.fillReport(jre, hm, con);
JasperExportManager.exportReportToHtmlFile(jr, "report1.html");
JasperViewer.viewReport(jr, false);
} catch (ClassNotFoundException ex) {
System.out.println(ex.getMessage());
} catch (SQLException se) {
System.out.println(se.getMessage());
} catch (JRException ex) {
System.out.println(ex.getMessage());
}
}
Also dont forget to include these jars into library :
public void ShowReport() {
try {
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/neosoft", "postgres", "postgres");
HashMap hm = new HashMap();
JasperReport jre;
jre = JasperCompileManager.compileReport("src//japi//report1.jrxml");
JasperPrint jr = JasperFillManager.fillReport(jre, hm, con);
JasperExportManager.exportReportToHtmlFile(jr, "report1.html");
JasperViewer.viewReport(jr, false);
} catch (ClassNotFoundException ex) {
System.out.println(ex.getMessage());
} catch (SQLException se) {
System.out.println(se.getMessage());
} catch (JRException ex) {
System.out.println(ex.getMessage());
}
}
Also dont forget to include these jars into library :
15 September 2011
JDBC PostgreSQL in JDeveloper
Here is how to solve postgresql jdbc driver installation for JDeveloper WebLogic 10.3.
1.) Download the driver from here (http://jdbc.postgresql.org/download.html). You will probably want to download the JDBC 4 driver. The downloaded file will be .zip, eventhough the weblogic requires .jar. For those who are beginners should know that Sun used .jar which is just another .zip file. Therefore rename the downloaded .zip to .jar.
2.) You can copy the file to C:\Oracle\Middleware\wlserver_10.3\server\lib .
3.) Open the following file C:\Oracle\Middleware\wlserver_10.3\common\bin\commEnv.cmd.
4.) Find the following line
set WEBLOGIC_CLASSPATH=%JAVA_HOME%\lib\tools.jar;%WL_HOME%\server\lib\weblogic_sp.jar;%WL_HOME%\server\lib\weblogic.jar;%FEATURES_DIR%\weblogic.server.modules_10.3.3.0.jar;%WL_HOME%\server\lib\webservices.jar;%ANT_HOME%/lib/ant-all.jar;%ANT_CONTRIB%/lib/ant-contrib.jar
and append ;%WL_HOME%\server\lib\postgresql-8.4-701.jdbc4.jar
so it becomes
set WEBLOGIC_CLASSPATH=%JAVA_HOME%\lib\tools.jar;%WL_HOME%\server\lib\weblogic_sp.jar;%WL_HOME%\server\lib\weblogic.jar;%FEATURES_DIR%\weblogic.server.modules_10.3.3.0.jar;%WL_HOME%\server\lib\webservices.jar;%ANT_HOME%/lib/ant-all.jar;%ANT_CONTRIB%/lib/ant-contrib.jar;%WL_HOME%\server\lib\postgresql-8.4-701.jdbc4.jar
5.) Make sure that the postgresql-8.4-701.jdbc4.jar reflects the postgres driver filename which you downloaded
6.) Restart the server
7.) Now if you go inside the Weblogic admin console and create a datasource you should be able to successfully test the configuration
Driver Class = "org.postgresql.Driver";
JDBC URL = "jdbc:postgresql://localhost:5432/neosoft";
USER = "postgres";
PASSWORD = "postgres";
source : Oracle Forum
1.) Download the driver from here (http://jdbc.postgresql.org/download.html). You will probably want to download the JDBC 4 driver. The downloaded file will be .zip, eventhough the weblogic requires .jar. For those who are beginners should know that Sun used .jar which is just another .zip file. Therefore rename the downloaded .zip to .jar.
2.) You can copy the file to C:\Oracle\Middleware\wlserver_10.3\server\lib .
3.) Open the following file C:\Oracle\Middleware\wlserver_10.3\common\bin\commEnv.cmd.
4.) Find the following line
set WEBLOGIC_CLASSPATH=%JAVA_HOME%\lib\tools.jar;%WL_HOME%\server\lib\weblogic_sp.jar;%WL_HOME%\server\lib\weblogic.jar;%FEATURES_DIR%\weblogic.server.modules_10.3.3.0.jar;%WL_HOME%\server\lib\webservices.jar;%ANT_HOME%/lib/ant-all.jar;%ANT_CONTRIB%/lib/ant-contrib.jar
and append ;%WL_HOME%\server\lib\postgresql-8.4-701.jdbc4.jar
so it becomes
set WEBLOGIC_CLASSPATH=%JAVA_HOME%\lib\tools.jar;%WL_HOME%\server\lib\weblogic_sp.jar;%WL_HOME%\server\lib\weblogic.jar;%FEATURES_DIR%\weblogic.server.modules_10.3.3.0.jar;%WL_HOME%\server\lib\webservices.jar;%ANT_HOME%/lib/ant-all.jar;%ANT_CONTRIB%/lib/ant-contrib.jar;%WL_HOME%\server\lib\postgresql-8.4-701.jdbc4.jar
5.) Make sure that the postgresql-8.4-701.jdbc4.jar reflects the postgres driver filename which you downloaded
6.) Restart the server
7.) Now if you go inside the Weblogic admin console and create a datasource you should be able to successfully test the configuration
Driver Class = "org.postgresql.Driver";
JDBC URL = "jdbc:postgresql://localhost:5432/neosoft";
USER = "postgres";
PASSWORD = "postgres";
source : Oracle Forum
31 August 2011
Close all MDI children forms
procedure T_c_form_desktop.FormClose(Sender: TObject; var Action: TCloseAction);
var
i : Word;
begin
inherited;
if MDIChildCount > 0 then
for i := 0 to MDIChildCount - 1 do MDIChildren[i].Close;
end;
var
i : Word;
begin
inherited;
if MDIChildCount > 0 then
for i := 0 to MDIChildCount - 1 do MDIChildren[i].Close;
end;
25 July 2011
Future of Lazarus / FreePascal
(This post was taken from excellent subject in Lazarus Forum)
... But thats because everybody wants web bases applications and no more locally installed applications so most of the industry is working on that, abandoning desktop applications.
"Everybody wants":THAT'S SIMPLY NOT TRUE!
I face 1 customer every 1000 who prefer a web app instead of a desktop one.
If we are talking of fashion ok... I'm italian... but the truth is that only some (AND FEW ONES ) scenarios can benefit from web based applications.
Simply ask to the extreme: what do you prefer, developing on your computer or using an online IDE? Do you prefere Aptana or Titanium? What you prefer a desktop chat client to put on the systray panel or a google chat in the browser?
Obviously if a global shared task manager is needed, surely web app is better.
But the main reason the industry/developers TRY to make everything web based, is for a WRONG paradigm: web app are OS independent and everywhere (or nowhere ). Yes, right, but are isolated from browsers, components (hundreds that born and die every year), servers, protocols, glue that interconnect a component/framework together, etc.?
Even entering the domain of what is "best" (at least more than system tools ) suited for web application, that is, business, financial and accounting management software, there are many caveats and problems, not only technical problems, but also legal and from from user point of view.
Some examples:
1) Usual user sentence when he try demo web apps: "It is too slow!!!". ALWAYS! Even using a Cray-X server! That's due to a more complicated verbose protocol. Even in the best case where java is used in the client side instead of JS, the overall software is perceived SLOW compared with a native/dedicated client.
Real case
Do you know Zurich Insurance? They had a DOS based software till last year, on novell LAN, called OASI. They have only recently changed to a web based equivalent software.
RESULT:EVERY USER feel this new application a down grade! Everyone feel it bad because of the low responsiveness compared to the previous super quick software. Obviuosly it's not a matter of money because Zurich... you know..., nor config: dedicated lines, backup lines, etc. The problem is that there is nothing to do for phisics reasons. As the best truck of the world can't compete with a Ferrari or a Lamborghini Gallardo so a web app cant compete with a desktop one.
Responsiveness and other features are the reasons you can find desktop clients even for twitter, facebook, and other web app etc.
What developers have to understand is that end users are not developers. They don't rejoice only because we have an easy life making "write once execute everywhere" web app. When a user see a click response after 1s he think: "WHAT A SLUGGISHNESS!!!! What's wrong? (click click click click click click)".
End users are not like us. If a user wants a car and you give him a truck, is not more happy reasoning that it is tecnologically better, can carry more stuff, has more value in the industry, and so is OK that is slower.
2)
I both develop RIA and Desktop applications. Small/medium companies that call us to buy a software, after 2 seconds ask: "Isn't a web software, right?" (That means: if it is a web app I'm not interested at all).
Why? Simple:
a) They want data on their LAN, not in fantasiland or distributed all over the clouds of the world even if we are proud to hilight "cloud server" or GlassFish in the brochure!
b) They want to work even when DSL is down, and are not interested if the app is slow because of the line.
They also want to work if notebook don't have a line (for many could seem strange but in many nations trains, bus and ferry boats are places that rarely or often NEVER have a hot spot).
c) They would like to work from a pen drive if needed.
d) They know that online software (at least in Italy) is subject to the Guardia di Finanza (italian police whose specific task is to enforce tax evasion laws etc) WITHOUT ANY ASK OR ADVICE.
3) Initially I was willing to simplify my work making web app for everything. I thought I could gather every user under the same web app simply changing the location of the server:
- installing the app/server on the customer LAN (VMware/VBox) to cope with the clients mandatory will to have a desktop app
- installing on the web for those who need global access and no installation, working even from a pub client.
... but today I ask myself: what is the real benefit againsts a real dedicated client? It's only because I can't give them pub client access?
So after some years I have the evidence that only some web solutions are really well accepted from the users:
1) Software intended for occasional use, touch and go
2) Software for the big mass (es. communication like facebook, twitter, gmail)... by the way... about google.... try asking people to use Google Apps instead of m$ Word . Have you ever tried a serious documents? Try the speed/responsiveness.
3) Software for huge companies where slowness is less important that everywhere + no maintainance (no manteinance... only idealistic idea! Let's say: Today is: I have all of the problems distributed on the cloud )
and I'm now oriented to:
1) Hybrid apps (web app only for some functions)
2) Portable app (real native executable), that are also useable the way java web start do.
This can cope with almost every need the best way we can (in the user view point).
Developer view
Despite I have no problem developing RIA applications (I have also developed a framework), to me, there is nothing more satisfying than working with native applications, for plenty of reasons. Beyond a certain line, it's even easier because RIA apps is not that panacea. The worst thing for a desktop app is OS changes.... but now browsers war, technologies that appear and disappear, frameworks, GUI components (YUI, etc), servers, etc, brings more changes and need of mainteinance than a desktop applications using something like lazarus, all in one.
Just an example: In a small web app, i'm using jQuery and some jQ visual components, plus TinyMce + AjaxFileManager. Some days ago I update jQuery: problems!
So there is no better relief developing web apps. Don't counting problems such as resize images client side before uploading, dialogue with a cash register and other devices, changing the printer if the software has to print an invoce, using another printer if it has to print a chart, or using a Zebra card printer if it has to print a new fidelity card. Let's do it with a web app! How easy is it?
Web apps are limited to some targets: out of that targets the only benefit are... problems!
Quote
Not sure if you are thinking that Swing itself is dead, but from what I have read, this is referring to an enhancement that was planned for Java 7 to build a framework around Swing to make it easier for developers to build Swing apps.
That's referring to what it says: Netbeans Platform.
About the Swing framework (the best way Netbeans had to compete with VB/Delphi/Lazarus/RealBasic/code:blocks/and the rest of the desktop world), what you see when you choose New Project->Desktop application, IS DEAD!.
Swing probably will last for a long time, but the web is full of question like: "Is Swing dead?" Probably there is a real reason!
Whatever the case, I don't trust Oracle! Sun was another matter. Oracle is very similar to m$: you can aspect everything, even they shut down Java tomorrow (exaggeration but... not too much ).
About Netbeans Platform: is something like developing.... how can I say.... just imagine developing under Open Office or Microsoft Access. The developer get tied to Netbeans more than Java. With the previous way, you could choose to migrate the app to Eclipse. With NetBeans Platform is not possibile anymore.
Even though I was not very attracted from Pascal (reason why times ago I used C++ Builder instead of Delphi), Lazarus is so interesting that I changed my mind and I'm seriously studying it (I exhumed from my shelf a tome of Marco Cantu` on Delphi 6 ).
So thanks to every developer and your great work with this product!
Blame the inexperienced developer, don't blame the tool.
From Lazarus forum
... But thats because everybody wants web bases applications and no more locally installed applications so most of the industry is working on that, abandoning desktop applications.
"Everybody wants":THAT'S SIMPLY NOT TRUE!
I face 1 customer every 1000 who prefer a web app instead of a desktop one.
If we are talking of fashion ok... I'm italian... but the truth is that only some (AND FEW ONES ) scenarios can benefit from web based applications.
Simply ask to the extreme: what do you prefer, developing on your computer or using an online IDE? Do you prefere Aptana or Titanium? What you prefer a desktop chat client to put on the systray panel or a google chat in the browser?
Obviously if a global shared task manager is needed, surely web app is better.
But the main reason the industry/developers TRY to make everything web based, is for a WRONG paradigm: web app are OS independent and everywhere (or nowhere ). Yes, right, but are isolated from browsers, components (hundreds that born and die every year), servers, protocols, glue that interconnect a component/framework together, etc.?
Even entering the domain of what is "best" (at least more than system tools ) suited for web application, that is, business, financial and accounting management software, there are many caveats and problems, not only technical problems, but also legal and from from user point of view.
Some examples:
1) Usual user sentence when he try demo web apps: "It is too slow!!!". ALWAYS! Even using a Cray-X server! That's due to a more complicated verbose protocol. Even in the best case where java is used in the client side instead of JS, the overall software is perceived SLOW compared with a native/dedicated client.
Real case
Do you know Zurich Insurance? They had a DOS based software till last year, on novell LAN, called OASI. They have only recently changed to a web based equivalent software.
RESULT:EVERY USER feel this new application a down grade! Everyone feel it bad because of the low responsiveness compared to the previous super quick software. Obviuosly it's not a matter of money because Zurich... you know..., nor config: dedicated lines, backup lines, etc. The problem is that there is nothing to do for phisics reasons. As the best truck of the world can't compete with a Ferrari or a Lamborghini Gallardo so a web app cant compete with a desktop one.
Responsiveness and other features are the reasons you can find desktop clients even for twitter, facebook, and other web app etc.
What developers have to understand is that end users are not developers. They don't rejoice only because we have an easy life making "write once execute everywhere" web app. When a user see a click response after 1s he think: "WHAT A SLUGGISHNESS!!!! What's wrong? (click click click click click click)".
End users are not like us. If a user wants a car and you give him a truck, is not more happy reasoning that it is tecnologically better, can carry more stuff, has more value in the industry, and so is OK that is slower.
2)
I both develop RIA and Desktop applications. Small/medium companies that call us to buy a software, after 2 seconds ask: "Isn't a web software, right?" (That means: if it is a web app I'm not interested at all).
Why? Simple:
a) They want data on their LAN, not in fantasiland or distributed all over the clouds of the world even if we are proud to hilight "cloud server" or GlassFish in the brochure!
b) They want to work even when DSL is down, and are not interested if the app is slow because of the line.
They also want to work if notebook don't have a line (for many could seem strange but in many nations trains, bus and ferry boats are places that rarely or often NEVER have a hot spot).
c) They would like to work from a pen drive if needed.
d) They know that online software (at least in Italy) is subject to the Guardia di Finanza (italian police whose specific task is to enforce tax evasion laws etc) WITHOUT ANY ASK OR ADVICE.
3) Initially I was willing to simplify my work making web app for everything. I thought I could gather every user under the same web app simply changing the location of the server:
- installing the app/server on the customer LAN (VMware/VBox) to cope with the clients mandatory will to have a desktop app
- installing on the web for those who need global access and no installation, working even from a pub client.
... but today I ask myself: what is the real benefit againsts a real dedicated client? It's only because I can't give them pub client access?
So after some years I have the evidence that only some web solutions are really well accepted from the users:
1) Software intended for occasional use, touch and go
2) Software for the big mass (es. communication like facebook, twitter, gmail)... by the way... about google.... try asking people to use Google Apps instead of m$ Word . Have you ever tried a serious documents? Try the speed/responsiveness.
3) Software for huge companies where slowness is less important that everywhere + no maintainance (no manteinance... only idealistic idea! Let's say: Today is: I have all of the problems distributed on the cloud )
and I'm now oriented to:
1) Hybrid apps (web app only for some functions)
2) Portable app (real native executable), that are also useable the way java web start do.
This can cope with almost every need the best way we can (in the user view point).
Developer view
Despite I have no problem developing RIA applications (I have also developed a framework), to me, there is nothing more satisfying than working with native applications, for plenty of reasons. Beyond a certain line, it's even easier because RIA apps is not that panacea. The worst thing for a desktop app is OS changes.... but now browsers war, technologies that appear and disappear, frameworks, GUI components (YUI, etc), servers, etc, brings more changes and need of mainteinance than a desktop applications using something like lazarus, all in one.
Just an example: In a small web app, i'm using jQuery and some jQ visual components, plus TinyMce + AjaxFileManager. Some days ago I update jQuery: problems!
So there is no better relief developing web apps. Don't counting problems such as resize images client side before uploading, dialogue with a cash register and other devices, changing the printer if the software has to print an invoce, using another printer if it has to print a chart, or using a Zebra card printer if it has to print a new fidelity card. Let's do it with a web app! How easy is it?
Web apps are limited to some targets: out of that targets the only benefit are... problems!
Quote
Not sure if you are thinking that Swing itself is dead, but from what I have read, this is referring to an enhancement that was planned for Java 7 to build a framework around Swing to make it easier for developers to build Swing apps.
That's referring to what it says: Netbeans Platform.
About the Swing framework (the best way Netbeans had to compete with VB/Delphi/Lazarus/RealBasic/code:blocks/and the rest of the desktop world), what you see when you choose New Project->Desktop application, IS DEAD!.
Swing probably will last for a long time, but the web is full of question like: "Is Swing dead?" Probably there is a real reason!
Whatever the case, I don't trust Oracle! Sun was another matter. Oracle is very similar to m$: you can aspect everything, even they shut down Java tomorrow (exaggeration but... not too much ).
About Netbeans Platform: is something like developing.... how can I say.... just imagine developing under Open Office or Microsoft Access. The developer get tied to Netbeans more than Java. With the previous way, you could choose to migrate the app to Eclipse. With NetBeans Platform is not possibile anymore.
Even though I was not very attracted from Pascal (reason why times ago I used C++ Builder instead of Delphi), Lazarus is so interesting that I changed my mind and I'm seriously studying it (I exhumed from my shelf a tome of Marco Cantu` on Delphi 6 ).
So thanks to every developer and your great work with this product!
Blame the inexperienced developer, don't blame the tool.
From Lazarus forum
Subscribe to:
Posts (Atom)