C# Basics / File I/O / Console App Flashcards
How would you display a line of text in the console?
Console.Write() - to continue on same line Console.WriteLine() - to start new line after displayed
What is string interpolation and how is it used?
String interpolation enables you to insert values in string literals to create formatted strings.
How would you read a sting literally or verbatim?
@”C:Windows\System32”
What is composite formatting of parameters?
{Index [, alignment][:formatString]
Console.WriteLine(“{0,-20} {1,5}\n”, “Name”, “Hours”);
// The example displays the following output:
// Name Hours
What is a list?
A list is similar to an array but provides additional functionality, such as dynamic resizing.
Define: Index
Index is a number starting from 0 that identifies a corresponding item in the list of objects.
Define: Alignment
Alignmet is a signed integer indicating the preferred formatted field width
Define: Format string
Format String is a format string that is appropriate for the type of object being formatted
What datatypes does C# read from the keyboard?
ONLY STRINGS, unline java, so the need for parsing is often used
How would you parse a readline to an integer?
What is the other way to convert a sting into an integer?
int myAge = Convert.ToInt32(input)
What is the naming convention for methods inside of a class in C#?
Pascal not camel case!
eg. SetName
How would you manually create a property to get and set the instance variable?
What would a Class diagram look like with a property?
How would you manually add validation to a property set method?
Private decimal balance: // instance variabl
How would you create an auto-implemented property?
public string Name { get; set; }
What is the format specifier for currency and how is it used?
Format Specifier :C