Unsafe code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon Milner

    Unsafe code

    How do I declare that my code is unsafe? Sorry the help
    files at my University have not been installed!
  • jeric

    #2
    Re: Unsafe code

    "Jon Milner" <anonymous@disc ussions.microso ft.com> wrote in message
    news:023601c3a9 57$8262ae60$a40 1280a@phx.gbl.. .
    : How do I declare that my code is unsafe? Sorry the help
    : files at my University have not been installed!


    Rigth click the project > properties > configuration properties > build >
    "allow unsafe code block"

    Set it to true. Also, your code has to be wrapped in an unsafe block.

    HTH


    Comment

    • 100

      #3
      Re: Unsafe code

      Hi Jon,

      You can use unsafe blocks inside your methods as
      unsafe
      {
      .....
      }

      Or you can mark a methods or entire class as unsafe

      unsafe class Foo
      {
      //All methods in the class are unsafe
      }

      or

      public unsafe void DoSomethingUnsa fe(...)
      {
      .....
      }

      Don't foreget to compile with */unsafe* option set. If you use VS .NET right
      click on the project node in the "Solution Explorer" then chose "Properties "
      and then in "Configurat ion Properties | Build" section set "Allow Unsafe
      Code Blocks" to true.

      BTW if you don't have help installed, but you have internet access you can
      use MSDN online msdn.microsoft. com.

      HTH
      B\rgds
      100


      "Jon Milner" <anonymous@disc ussions.microso ft.com> wrote in message
      news:023601c3a9 57$8262ae60$a40 1280a@phx.gbl.. .[color=blue]
      > How do I declare that my code is unsafe? Sorry the help
      > files at my University have not been installed![/color]


      Comment

      • Ron Vecchi

        #4
        Re: Unsafe code

        Just browsiung the posts...
        What is unsafe code?


        "Jon Milner" <anonymous@disc ussions.microso ft.com> wrote in message
        news:023601c3a9 57$8262ae60$a40 1280a@phx.gbl.. .[color=blue]
        > How do I declare that my code is unsafe? Sorry the help
        > files at my University have not been installed![/color]


        Comment

        • Joe Mayo

          #5
          Re: Unsafe code


          "Ron Vecchi" <rvecchi@xilehd vecchi.com> wrote in message
          news:ux9dtWXqDH A.3688@TK2MSFTN GP11.phx.gbl...[color=blue]
          > Just browsiung the posts...
          > What is unsafe code?[/color]

          Hi Ron,

          If you want to work with pointers, you would wrap that code in an unsafe
          code block. The code may in fact be safe, but the CLR can't verify it.

          Joe
          --
          Welcome to C# Station!  This is a community site for people interested in applying .NET using the C# programming language.  We’ve been around since July 4th 2000 and have continued to grow over the years.  Items of interest include Articles, Books, Links, Documentation,  and Tutorials. More… Source Code If you would like to see an […]



          Comment

          Working...