Per darti un'idea ....
codice:
/*
* Created by SharpDevelop.
* User: Brainjar
* Date: 31/01/2007
* Time: 8.52
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
namespace esempio_02
{
class MainClass
{
private static string foreName;
public static string ForeName
{
get
{
return foreName;
}
set
{
if (value.Length > 20)
Console.WriteLine("Il valore è maggiore di 20!");
else {
foreName = value;
Console.WriteLine("Il valore non è maggiore di 20!");
}
}
}
public static void Main(string[] args)
{
ForeName = "George Bush";
Console.WriteLine("Hello " + ForeName);
}
}
}