Unable to build code I copied from an article
I have this code that I copied from Mike Bluestein's article on sending e-mail from an app. Unfortunately, I get the foll开发者_Python百科owing error on line 5:
Unexpected symbol 'public'
What am I missing?
You copied it into a method. The code you copied defines a member variable at a class level and then a couple methods.
It looks to be just a sample taken out of a larger codebase, so even if you just paste it into a class, it probably still won't work as you expect (if at all). Instead of blindly copy/pasting you want to read through the article and the example to understand what it's doing and then replicate it in your own code.
I second Konrad's suggestion: you may want to brush up on C# first.
I added a link to the sample project at the bottom of the blog post. I hope that helps.
精彩评论