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

A

csharp

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
Q

c#: To create an if, else if, else statement, type

A
if (varName == "string") {
  ...
}
else if
{
  ...
}
else
{
  ...
}
26
Q

c#: To make a loop start back from the beginning, type

A

continue;

27
Q

c#: To create a try catch statement, type

A

try
{

}
catch(ExceptionName)
{

}

28
Q

c#: variables are only

A

accessible from within the curly brackets they were declared in. Not in parallel or parent brackets, only child brackets.

29
Q

c#: To convert a string to lower case, type

A

stringVar.ToLower()

30
Q

c#: The type that can hold decimals is

A

double

31
Q

c#: To declare a double, type

A

double varName = 10.0;

32
Q

c#: To make a variable available in parent brackets

A

declare the variable in them and just initialize it in the child brackets

33
Q

c#: Any equation using both an int and a double returns

A

a double

34
Q

c#: Any equation of two ints will return

A

an int

35
Q

c#: To cast an double into an int, type

A

(int)(10.0)

36
Q

c#: Casting a number does not

A

round it. It truncates.

37
Q

c#: To create a variable without declaring it’s type, type

A

var varName = 0;

38
Q

c#: DNX stands for

A

the .Net execution environment

39
Q

c#: When debugging always ensure that

A

all lines end with ;

40
Q

c#: To add references in Xamarin

A

Hover over the References folder
Click gear button
In the menu click “add references”

41
Q

c#: “using” statements automatically

A

call the dispose function on the object after it is used

42
Q

c#: To send an http get request, type

A

using System;
using System.Net;
using System.IO;
using System.Net.Http;

using (WebClient client = new WebClient())
{
  htmlCode = client.DownloadString("http://site.com");
}
43
Q

c#: To initialize an int array var with array values, type

A
int[] varName = new int[5] {1,2,3,4,5}
or
var varName = new int[5] {1,2,3,4,5}