Ideally, no. Screenshots are considered a bad practice here, post formatted code instead. Here is how to do it:
Although, if you don't have another option, they are better than nothing.