Only assignment, call, increment, decrement, and new object expressions can be used as a statement.
The documentation says to a statement:
The actions that a program takes are expressed in statements. Common actions include declaring variables, assigning values, calling methods, looping through collections, and branching to one or another block of code, depending on a given condition
Your basic problem is that you are missing the ( )
parentheses that will tell the compiler that you want to call a method in these lines:
cs.Close;
ms.Close;
so change them to :
cs.Close();
ms.Close();
Otherwise the compiler thinks you try to access a field or a property and tells you that this cannot stand alone as a statement. As the error message states you can do either:
assignment,
int c = ms.Capacity;
call
ms.Close();
increment, decrement
ms.Capacity++;
new object expressions
new MemoryStream();