C# Terms Flashcards

C# terms from week 1 & 2 of Centriq's C# Fundamentals class

1
Q

**VARIABLE **

A

- a storage container which holds the data for the runtime of the program. - must be of “type something” i.e. int, string, bool, decimal, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

DATA TYPE

A
  • all variables must be of “type” something in .Net…
  • data type specifies the range and/or type of information a variable can hold, and methods available to it.

Examples: byte, short, int, long, float, double, decimal, bool, char, string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

BASIC DATA TYPE

A

byte, short, int, long, float, decimal,

double, bool, char, string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

DECLARE

A

The 1st time you create

(by naming & giving a data type to) a variable.

Example: int x;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

INITIALIZE

A

the first time you assign value to a variable.

Example: int y = 5; OR x = 20;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

ASSIGN VALUE

A

- setting a value to be held by a variable.

- does not have to be the “first time” a value has been assigned to the variable.

Example: int z = 1; OR y = 109;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

an object

A

An actual instance that has been created from a class.

Example: bool isTrue = true; int lamps = 99; Random nbrGenerator = new Random(); DateTime thisDay = new DateTime (2010, 1, 27)

…where isTrue, lamps, nbrGenerator and this Day are all objects of their respective classes (Bool, Int32, Random, DateTime). Similar to variable and instance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Object

A

The Object class is from the Framework Class Library (FCL); it is the top-tier class from which all other classes inherit.

********** extra info… - this means that at a base level we can say that all objects (instances of any class) also inherit from the base class Object. So no matter what class an object is an instance of, it is also an instance of the Object class and inherits certain properties and methods (like ToString());

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

CLASS

A
  • sometimes called a blueprint…from which you make real houses (instances/objects)
  • or a template from which you make real things (instances/objects).
  • A class ~ data type… A class can essentially provide the definition to create variables of that data type.
  • Classes are a collection of types of information and specific behaviors that are modeled after real-world things you will need to work with in your program (employees, volunteers, shopping carts, products, customers, etc).

By making a class to hold information about any given employee, and by including behaviors that any employee should be able to do, you can instantiate (create an instance of) the Employee class you made – and know that every employee will be able to store certain information about itself (firstName, lastName, dateOfHire, etc) and be able to perform certain behaviors (ClockIn(), ClockOut(), ScheduleMeeting()) etc…

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

INSTANCE (OF SOMETHING)

A

Usually stated “an instance of X” where X is a class. Similar to variable and object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

INSTANTIATE

A

to create an object/instance from some class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

METHOD

A

the “verbs” of our language, methods perform some action or block of code when called. The Main() method runs automatically when a program is launched and is called the “entry point of the program”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

STATIC METHOD

A

- opposite of an “instance method”

- a static method is called w/o creating an instance of the class in which the method is declared.

Examples: Console.WriteLine(), Main(), or DisplayNow() below (note void in declaration, and no instance of MethodsEx1 class needed to call it from Main().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

INSTANCE METHOD

A

The default access modifier for a method, an instance method requires you to have an instance of the class it’s created inside in order to call it. You won’t declare a method as an instance method unless you plan to make objects from the class in which you’re declaring the method. Example: Note the source code file (ClassesIntro.cs) contains a new class for Dog, and Dog has its own methods. If you want individual Dog objects to be able to perform that method, you’ll need to make them instance methods. You can leave off the word “instance” in your Bark() method because the default access modifier defaults to instance. You’ll need a Dog object before you can call it from Main():

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

RETURN TYPE

A

Specified when declaring a method. Designates what data, if any, should be “returned” as a result of running the method. A method that just runs a Console.WriteLine() method that displays a result of calculations is not “returned data”. If no “data will be returned”, the return type is “void”. If your return type is not void, it should specify a data type of the data you will return(string, int, bool, Random, DateTime, etc). ALSO, you will need a return statement at the end that lets you choose what actual data to return (its data type must match the return type you specified). Examples below show a method declared with a void data type (ShowFinedPaycheck()) and one that returns a decimal (ReturnPaycheckAmount());

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

SIGNATURES

A

a unique parameter set for a method declaration. If a method can only be performed with 1 parameter set, it has 1 signature and is not “overloaded”. If there are multiple declarations for the same method, with different signatures, it is said to be “overloaded”, and calling the method using different parameter sets may result in different versions of the method code being run. (One signature may process the method a certain way, whereas another signature may process it another way.)

17
Q

OVERLOADS

A

When a method has more than one declaration, and uses different signatures for each. see signatures.

18
Q

STRUCT

A

- a “paired-down” version of a class.

- Usually a quicker approach to creating a template for collecting related information (firstName, lastName, yearsWithCompany) than a class, but doesn’t support inheritance, etc.

19
Q

SCOPE

A

- The “territory/memory” of a block of code. - Often associated with curly brace structures.

Examples: if{} OR Main() {} OR while(){}

…where the scope is inside those code blocks. Variables created inside these curly braces are “local” to that scope and often cannot be accessed from outside that scope.

20
Q

ARRAYS

A

Like a container of variables of the same data type. Must have a specified Length(number of indexes or slots) when declared. Length cannot be changed programmatically.

21
Q

LOOPS

A

a technique which allows a code block to be repeated until a certain test condition fails
(or in the case of a foreach, until all the items in a collection have been “run through”).

22
Q

PARAMETERS

A

data that a method will use to perform its function. specified in the method’s declaration. Must be given a data type.

23
Q

ARGUMENTS

A

data given when calling a method so it can perform its function. Must match a signature (parameter set) specified in the method’s declaration.

24
Q

DECLARE A METHOD

A

defining the access modifiers, return type, name and parameters of a method, as well as what it will do.

25
Q

CALL A METHOD

A

calling a method to perform its action, passing whatever arguments are needed to be used as parameters.

26
Q

CTOR /

CONSTRUCTOR

A

a specialized method within a class definition (with the same name as that class) that lets you create objects from the class. You get a default, free ctor that accepts no parameters and assigns no values to the object you create. If you create your own, you’ll have “destroyed” the default ctor that accepts no parameters, but you can build it back as an overload. ctor stands for “constructor”.

Note: Example below does not show proper encapsulation using properties.