using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication10
{
public class MyException : Exception
{
public readonly int MyValue;
public long MyTest
{
get;
private set;
}
public MyException (int value)
{
this.MyValue = value;
this.MyTest = 1 << value;
}
public override string ToString ()
{
return String.Format ("MyException ({0}:{1})", MyValue, MyTest);
}
}
public class Foo
{
public int Data;
protected int Data2;
private int Data3;
public int Data4;
internal int Data5;
protected double TestProperty
{
get { return Data * Math.E; }
}
internal static long StaticData;
private static double StaticTest
{
get { return StaticData * Math.PI; }
}
public Foo (int data)
{
this.Data = data;
this.Data2 = 2 * data;
this.Data3 = 3 * data;
this.Data4 = 4 * data;
this.Data5 = 5 * data;
StaticData = 1 << data;
}
public void Test ()
{ }
public override string ToString ()
{
return String.Format ("Foo ({0}:{1}:{3}:{4}:{5}:{6}:{7})",
Data, Data2, Data3, Data4, Data5, StaticData, StaticTest, TestProperty);
}
}
public class Bar : Foo
{
public Bar ()
: base (11)
{ }
}
class X
{
public DateTime Test
{
get { return DateTime.Now; }
}
public long Error
{
get { throw new MyException (9); }
}
#if FIXME
public int Timeout
{
get { while (true) ; }
}
#endif
public X (int a)
{
this.A = a;
}
protected readonly int A;
void Hello ()
{
Console.WriteLine (A);
}
void Method (out int a)
{
a = 9;
}
public override string ToString ()
{
throw new MyException (11);
}
static void Main (string[] args)
{
Foo foo = new Foo (9);
foo.Test ();
Bar bar = new Bar ();
bar.Test ();
X x = new X (5);
x.Hello ();
int a;
x.Method (out a);
try
{
Console.WriteLine (x.Error);
}
catch (Exception ex)
{
Console.WriteLine (ex.Message);
}
}
}
}