Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Writing a custom exception and the "meaning" of the code

Writing a custom exception and the "meaning" of the code

Scheduled Pinned Locked Moved C#
csharpvisual-studiojsonquestionlearning
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kaare Tragethon
    wrote on last edited by
    #1

    Hi. I'm a total beginner in C# (and PC programming), but I'm starting to get the logic to work allright so I've got some hours in front of the computer. A couple of days ago I wanted to throw my own exception and I used the intellisense codesnippet to generate a new custom exception class. This works great and I have no problems using it, however I do not fully understand WHAT the lines of code actually do (how they work and what they are for). Since I got it working, I guess I really don't have to know what it does (since it is in fact working), however to expand my knowledge (and possible learn some tricks for the future) I would like to know what each line of the auto-generated code actually does, and what it is for. Would anyone please do a quick explain of the code? I have pasted the auto-generated code here:

        \[global::System.Serializable\]
        public class IndexException : Exception
        {
            //Autogenerated code
            public IndexException() { }
            public IndexException(string message) : base(message) { }
            //public IndexException(string message, Exception inner) : base(message, inner) { }
            protected IndexException(
              System.Runtime.Serialization.SerializationInfo info,
              System.Runtime.Serialization.StreamingContext context) 
                : base(info, context) { }
        }
    
    N 1 Reply Last reply
    0
    • K Kaare Tragethon

      Hi. I'm a total beginner in C# (and PC programming), but I'm starting to get the logic to work allright so I've got some hours in front of the computer. A couple of days ago I wanted to throw my own exception and I used the intellisense codesnippet to generate a new custom exception class. This works great and I have no problems using it, however I do not fully understand WHAT the lines of code actually do (how they work and what they are for). Since I got it working, I guess I really don't have to know what it does (since it is in fact working), however to expand my knowledge (and possible learn some tricks for the future) I would like to know what each line of the auto-generated code actually does, and what it is for. Would anyone please do a quick explain of the code? I have pasted the auto-generated code here:

          \[global::System.Serializable\]
          public class IndexException : Exception
          {
              //Autogenerated code
              public IndexException() { }
              public IndexException(string message) : base(message) { }
              //public IndexException(string message, Exception inner) : base(message, inner) { }
              protected IndexException(
                System.Runtime.Serialization.SerializationInfo info,
                System.Runtime.Serialization.StreamingContext context) 
                  : base(info, context) { }
          }
      
      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Have a look here[^] and here[^]


      only two letters away from being an asset

      K 1 Reply Last reply
      0
      • N Not Active

        Have a look here[^] and here[^]


        only two letters away from being an asset

        K Offline
        K Offline
        Kaare Tragethon
        wrote on last edited by
        #3

        Thanks a lot!! I've already seen the msdn article (which for me who don't know very much about PC programming yet did not help my understanding very much). However, the other article looks great!! Thanks again!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups