• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/18

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

18 Cards in this Set

  • Front
  • Back
In which two ways may a parameter be passed?
By value or by reference.
How can you force a value type to be passed by reference?
By using the 'ref' or 'out' modifier on the parameter.
What is the difference between a value type and a reference type parameter.
A value type parameter passes its data directly. A reference type passes a reference to its data.
If a method changes the value of a component of a value-type parameter does that change persist after the method terminates?
No. Value-type parameters pass a copy to the method which goes out of scope as soon as the method terminates.
How does using the 'ref' or 'out' modifier affect value-type parameters?
The 'ref' or 'out' modifier causes a reference to the parameter to be passed to the method. Thus, modifications to members of the parameter will persist after the method terminates.
Create a method that will permanently swap the values of two int type parameters.
public void intSwap(ref int x, ref int y)
{
int temp = x;
x = y;
y = temp;
}
How is a reference-type parameter passed?
A reference-type is passed by passing only a reference to the parameter. Thus, it is possible to modify the members of the parameter permanently.
Is it possible to change the value of the reference, i.e., make the reference point to a different object.
Yes, this is done by passing the reference type using the 'ref' modifier. Inside the method you either create a new object or assign an existing object to the the reference parameter. Note, that the original object that the reference pointed to can be orphaned, which will cause it to be destroyed by the garbage collector.
What is the purpose of the 'Main()' method?
The 'Main()' method provides an entry point for a program.
What is the purpose of parameters for the 'Main()' method?
This provides a way of passing values to the program from the command line.
What are the permissible return types for the 'Main()' method?
'Main()' may either return 'void' or an 'int'. The 'int' return type provides a way of reporting execution status (e.g., errors) to the operating system in the command-line mode.
Write a brief 'Main()' declaration that accepts command line arguments.
static void Main(string[] args)
{
...
}
The arguments are read by iterating through the args array.
Show three ways to convert a command line string-type argument to a numeric value.
long num = Int64.Parse(args[0]);
long num = long.Parse(args[0]);
long num = Convert.ToInt64(args[0]);
How does one build a macro in C#?
Trick question! Macros are not part of the C# language.
What are the two ways to define a preprocessor directive in C#?
use the '#define' directive or use the command line '/d' (/define option).
In which namespace are the trace and debug diagnostics contained.
System.Diagnostics.Trace and System.Diagnostics.Debug
Show a simple example of a method that uses conditional compilation to effect a trace.
Using System;
Using System.Diagnostics;
...
[Conditional("DEBUG")]
public void TraceMessage(string msg)
{
Console.WriteLine("[Trace]" + msg);
}
...
What restrictions are placed upon using the [Conditional()] attribute with methods?
The method cannot be an interface method and its return type must be void.