c# Flashcards

1
Q

c#: To create a class, type

A
class ClassName
{

}

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

c#: To write a method that doesnt return anything, type

A

static void MethodName()
{

}

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

c#: the first mandatory method called in any script is

A

static void Main()
{

}

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

c#: To create a comment, type

A

//

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

c#: .NET is

A

the library ecosystem that c# can import and use

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

c#: You must end all lines with a

A

;

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

c#: A common compiler for c# is

A

mono

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

c#: You can compile c# scripts using mono by typing

A

mcs ScriptName.cs

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

c#: You run c# scripts on mac or linux, type

A

mono ScriptName.exe

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

c#: To initialize a string variable, type

A

string varName = “string”;

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

c#: To write to the console, type

A

System.Console.Write(“string”);

System.Console.WriteLine(“string”);

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

c#: To get input into the console, type

A

System.Console.ReadLine();

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

c#: Methods are

A

capitalized

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

c#: Method calls in c# require you to

A

call the namespace, then the class, then the method

NameSpaceName.ClassName.MethodName();

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

c#: To set the namespace, type

A

namespace NameSpaceName
{

}

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

c#: To avoid having to write the namespace, type

A

using NameSpaceName

note: No ;

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

c#: Namespaces can be named

A

NameSpaceName.NameSpaceName.NameSpaceName

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

c#: To enter the c# repl, type

19
Q

c#: The types are

A

int
double
string

20
Q

c#: To convert a number string into an int, type

A

int.Parse(“10”)

21
Q

c#: types can also have

A

methods.

e. g.
int. Parse(“10”)

22
Q

c#: To initialize a variable with a boolean value, type

A

bool varName = false;

23
Q

c#: To create a while loop, type

A

bool varName = true;

while(varName == true)
{
Console.WriteLine(“string”);
}

24
Q

c#: To create an if else statement, type

A
if (varName == "string") {
  ...
}
else
{
  ...
}
25
c#: To create an if, else if, else statement, type
``` if (varName == "string") { ... } else if { ... } else { ... } ```
26
c#: To make a loop start back from the beginning, type
continue;
27
c#: To create a try catch statement, type
try { } catch(ExceptionName) { }
28
c#: variables are only
accessible from within the curly brackets they were declared in. Not in parallel or parent brackets, only child brackets.
29
c#: To convert a string to lower case, type
stringVar.ToLower()
30
c#: The type that can hold decimals is
double
31
c#: To declare a double, type
double varName = 10.0;
32
c#: To make a variable available in parent brackets
declare the variable in them and just initialize it in the child brackets
33
c#: Any equation using both an int and a double returns
a double
34
c#: Any equation of two ints will return
an int
35
c#: To cast an double into an int, type
(int)(10.0)
36
c#: Casting a number does not
round it. It truncates.
37
c#: To create a variable without declaring it's type, type
var varName = 0;
38
c#: DNX stands for
the .Net execution environment
39
c#: When debugging always ensure that
all lines end with ;
40
c#: To add references in Xamarin
Hover over the References folder Click gear button In the menu click "add references"
41
c#: "using" statements automatically
call the dispose function on the object after it is used
42
c#: To send an http get request, type
using System; using System.Net; using System.IO; using System.Net.Http; ``` using (WebClient client = new WebClient()) { htmlCode = client.DownloadString("http://site.com"); } ```
43
c#: To initialize an int array var with array values, type
``` int[] varName = new int[5] {1,2,3,4,5} or var varName = new int[5] {1,2,3,4,5} ```