Is there any difference between using keyword unsafe before method or before block of code?
Will it be wrong if I use it before method when i have only few lines of unsafe code and hundreds of safe code?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is a subjective answer but I’d use
unsafeon the method level, like this:When you use
unsafeinside the body of the function, it’s hidden away and it’s hard to find, while something like this should be very apparent. Everybody will read the function declaration but not everyone will go into the function body, unless they need to.Having
unsafein the declaration makes it stand out more.