14:
DataContext Class: Replace SQL Connection
Table Class: Reflects all fields in the database table.
DataTable dt = new DataTable();dt.Columns.Add("Column1", typeof(String)); // First col is a stringdt.Columns.Add("Column2", typeof(Boolean)); // Second col is a booleanDataRow dr = dt.NewRow();dr["Column1"] = "Data";dr["Column2"] = true;dt.Rows.Add(dr);dataGridView1.DataSource = dt;null:double SumNumbers(List<double[]> setsOfNumbers, int indexOfSetToSum)
{
return setsOfNumbers?[indexOfSetToSum]?.Sum() ?? double.NaN;
}
var sum = SumNumbers(null, 0);
Console.WriteLine(sum); // output: NaN
?? returns the value of its left-hand operand if it isn't null; otherwise, it evaluates the right-hand operand and returns its result. The ?? operator doesn't evaluate its right-hand operand if the left-hand operand evaluates to non-null.a ?? b ?? c
a ?? (b ?? c)
?? operator can be useful in the following scenarios:<inventory> <drink> <lemonade> <price>$2.50</price> <amount>20</amount> </lemonade> <pop> <price>$1.50</price> <amount>10</amount> </pop> </drink> <snack> <chips> <price>$4.50</price> <amount>60</amount> </chips> </snack> </inventory>
int and double, inherit from a single root object type. Thus, all types share a set of common operations, and values of any type can be stored, transported, and operated upon in a consistent manner. Furthermore, C# supports both user-defined reference types and value types, allowing dynamic allocation of objects as well as in-line storage of lightweight structures.@ as a prefix. For example, @if is a valid identifier, but if is not because if is a keyword.public delegate int MyDelegate (string s);
public delegate void printString(string s); ... printString ps1 = new printString(WriteToScreen); printString ps2 = new printString(WriteToFile);