final Flashcards
(56 cards)
The using directive has three uses:
Tells the compiler where to look for a class that is used in the Application
- To allow the use of types in a namespace so that you do not have to qualify the use of a type in that namespace: using System.Text;
- To allow you to access static members of a type without having to qualify the access with the type name
- To create an alias for a namespace or a type.
White space – space bar, tab, blank lines
white space DOES NOT MATTER to the compiler.
Public class, naming conventions for identifiers: letters, digits underscores
no spaces allowed when naming a variable, method, or class!
Class and method names should always have a capitalized first letter!
write
keeps everything on one line
writeLine
finishes the method execution by moving to the next line
\n
move to next line
\t
tab
\r
‘carriage return’(moves cursor to beginning of current line)
Using variables, data types
Reading in variables
Console.readLine( );
- or if you’re assigning it -
varType varName = Console.readLine( );
int x = Console.ReadLine( );
/
returns the last whole number after a division operation
11/5 = 2
%
returns the remainder after a division operation
11%5 = 1
Simple Data types
int (short,long, etc.), bool, char, double, decimal
Complex Data types
String, and any other user-created object(like the account class from assignment 5)
Order of Operations
=, !=, , <=, >=
Building a class
public class Blah { constructor, methods, whatev; }
creating an object of a class in another class
Account whatev= new Account(parameters go here if you need any);
calling a method of the class
ClassName.Method(method params);
Instance Variable
a variable declared in a class that each object of that class has a copy of
Public properties
a variable with methods defined to access and modify its variable
Auto-implemented Property
public double TotalPurchases { get; set; };
Constructor
public ClassName(*params) {
} -Used to ‘construct’ an instance of a class
Method
public return type name(params)
ex. public int x (parameters)
{
}
-Used to run specific operations, functions, or procedures on an object
If-else
If (logical condition) { *do this stuff* } else { *do this other stuff* }
Nesting
using a second if-else structure inside an if statement. Similar to nested for loops