Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- [assembly: Trace.QuickTrace(AttributeTargetAssemblies = "PostSharpIntro", AttributeTargetTypes = "PostSharpIntro.*")]
- namespace PostSharpIntro
- {
- class Program
- {
- static void Main(string[] args)
- {
- System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(Console.Out));
- try
- {
- var calculator = new Calculator();
- int a = 7, b = 5, result;
- string message = "Welcome to the PostSharpIntro project";
- Console.WriteLine(message);
- result = calculator.Add(a, b);
- message = string.Format("{0} add {1} equals {2}", a, b, result);
- Console.WriteLine(message);
- result = calculator.Subtract(a, b);
- message = string.Format("{0} subtract {1} equals {2}", a, b, result);
- Console.WriteLine(message);
- calculator.RunUnstableCode();
- }
- catch (Exception e)
- {
- Console.WriteLine(e.Message);
- }
- finally
- {
- Console.WriteLine("Press any yet to exit...");
- Console.ReadKey();
- }
- }
- public class Calculator
- {
- internal int Add(int a, int b)
- {
- return a + b;
- }
- internal int Subtract(int a, int b)
- {
- return a - b;
- }
- internal void RunUnstableCode()
- {
- throw new Exception("Houston, we have a problem!");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment