CustomException is an application exception that supports remoting. : Custom Exception : Language Basics C# Examples


C# Examples » Language Basics » Custom Exception »

 

CustomException is an application exception that supports remoting.









    
using  System;
using  System.Reflection;
using  System.Runtime.Serialization;

[assembly:  AssemblyVersion("1.1.0.0")]
[assembly:  AssemblyCultureAttribute("")]


[Serializable]
public  class  CustomException  :  Exception  {

        public  CustomException():  base("custom  exception",  null)  {
                prop_Time  =  DateTime.Now.ToLongDateString()  +  "  "  +  DateTime.Now.ToShortTimeString();
        }

        protected  CustomException(SerializationInfo  info,StreamingContext  context)
                :  base(info,  context)  {
                prop_Time  =  info.GetString("Time");
        }

        public  override  void  GetObjectData(SerializationInfo  info,  StreamingContext  context)  {
                info.AddValue("Time",  prop_Time,  typeof(string));
                base.GetObjectData(info,  context);
        }

        protected  string  prop_Time  =  null;
        public  string  Time  {
                get  {
                        return  prop_Time;
                }
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Language Basics
» Custom Exception