多语言展示
当前在线:919今日阅读:100今日分享:18

Debugging and Error Handling(一)

Debugging and Error Handling
工具/原料

visual studio2015

MAJOR ERROR TYPES
1

syntax, execution, and logicSyntax ErrorsSyntax errors, the easiest type of errors to spot and fix, occur when the code you have written cannot be understood by the compiler because instructions are incomplete, supplied in unexpected order, or cannot be processed at all. An example of this would be declaring a variable of one name and misspelling this name in your code when you set or query the variable. This is hard to find if you turn off Option Explicit.The development environment in Visual Studio 2015 has a very sophisticated syntax-checking mechanism, making it hard, but not impossible, to have syntax errors in your code. It provides instant syntax checking of variables and objects and lets you know immediately when you have a syntax error.Suppose you try to set a variable that is not declared in a procedure. Visual Studio 2015 underlines the variable with a red wavy line, indicating that the declaration is in error as shown in picture at the bottom!

2

If the integrated development environment (IDE) can automatically correct the syntax error, you’ll see a little yellow light bulb when you hover over the red underline or have your cursor on that line of code, as shown in Figure next (minus the color), indicating that the IDE has potential fixes available for this syntax error. This is a feature of Visual Studio 2015 that provides error-correction options that the IDE will suggest to correct the error using quick actions and a light bulb. Green underlines indicate a warning.

3

These IntelliSense features provide two major benefits. First, you do not have to remember all the available members for the class. You simply scroll through the list to find the member that you want to work with, or you type the first letter or two of the member to see a list reduced to the relevant members. To select the member in the list that you want to work with, you press the Tab or Enter key or double-click the member. Second, the features help you prevent syntax errors because you are less likely to misspell member names or try to use members that do not exist in the given class.

推荐信息