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. How can i disable temporarily warnings/error from the code?

How can i disable temporarily warnings/error from the code?

Scheduled Pinned Locked Moved C#
questioncsharpc++helptutorial
7 Posts 4 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.
  • E Offline
    E Offline
    e laj
    wrote on last edited by
    #1

    In VC++ was the #pragma warning directive, for example: #pragma warning( push ) // Store the current warning level for all warnings #pragma warning( disable : 4705 ) #pragma warning( disable : 4706 ) #pragma warning( disable : 4707 ) // Some code goes here... #pragma warning( pop ) // Pops the last warning level Is there any directive in C# that do the same job? Thanx in advanced!

    K W D 3 Replies Last reply
    0
    • E e laj

      In VC++ was the #pragma warning directive, for example: #pragma warning( push ) // Store the current warning level for all warnings #pragma warning( disable : 4705 ) #pragma warning( disable : 4706 ) #pragma warning( disable : 4707 ) // Some code goes here... #pragma warning( pop ) // Pops the last warning level Is there any directive in C# that do the same job? Thanx in advanced!

      K Offline
      K Offline
      Kevin McFarlane
      wrote on last edited by
      #2

      Project Properties -> Configuration Properties -> Suppress Specific Warnings Kevin

      E 1 Reply Last reply
      0
      • E e laj

        In VC++ was the #pragma warning directive, for example: #pragma warning( push ) // Store the current warning level for all warnings #pragma warning( disable : 4705 ) #pragma warning( disable : 4706 ) #pragma warning( disable : 4707 ) // Some code goes here... #pragma warning( pop ) // Pops the last warning level Is there any directive in C# that do the same job? Thanx in advanced!

        W Offline
        W Offline
        Wayne Phipps
        wrote on last edited by
        #3

        I believe you can only do this using v2.0 of the .Net Framework #pragma warning disable 0169, 0414 Regards Wayne Phipps ____________ Time is the greatest teacher... unfortunately, it kills all of its students View my Blog

        1 Reply Last reply
        0
        • E e laj

          In VC++ was the #pragma warning directive, for example: #pragma warning( push ) // Store the current warning level for all warnings #pragma warning( disable : 4705 ) #pragma warning( disable : 4706 ) #pragma warning( disable : 4707 ) // Some code goes here... #pragma warning( pop ) // Pops the last warning level Is there any directive in C# that do the same job? Thanx in advanced!

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          This is documented right here[^]. This is NOT SUPPORTED in C# 1.0 and 1.1. This is a new capability introduced in C# 2.0. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          E 1 Reply Last reply
          0
          • D Dave Kreskowiak

            This is documented right here[^]. This is NOT SUPPORTED in C# 1.0 and 1.1. This is a new capability introduced in C# 2.0. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            E Offline
            E Offline
            e laj
            wrote on last edited by
            #5

            THANX

            1 Reply Last reply
            0
            • K Kevin McFarlane

              Project Properties -> Configuration Properties -> Suppress Specific Warnings Kevin

              E Offline
              E Offline
              e laj
              wrote on last edited by
              #6

              THANX kevin, however - this setting is global to the project, to supress specific warning in specific portion of code and the restore it - now i have learned (by the other replyers of this post) that it is possible in .net 2.0 framework. Regards, ilan

              K 1 Reply Last reply
              0
              • E e laj

                THANX kevin, however - this setting is global to the project, to supress specific warning in specific portion of code and the restore it - now i have learned (by the other replyers of this post) that it is possible in .net 2.0 framework. Regards, ilan

                K Offline
                K Offline
                Kevin McFarlane
                wrote on last edited by
                #7

                Cool. I didn't know that. :) Kevin

                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