Core C# and .NET Quick Reference - cheat sheets

[Pages:2]Core C# and .NET Quick Reference

1. Data Types

Primitive

string bool char byte short int long float double decimal

Size 2 bytes/char

2 bytes 1 byte 2 bytes 4 bytes 8 bytes 4 bytes 8 bytes 16 bytes

2. Arrays

Example

s = "reference"; b = true; ch = `a'; b = 0x78; Ival = 54; Ival = 540; ival = 5400; val = 54.0F; val = 54.0D; val = 54.0M;

Declaration int[] numArray = {1903, 1907, 1910}; int[] numArray = new int[3]; // 3 rows and 2 columns int[ , ] nums = {{1907, 1990}, {1904, 1986}, {1910, 1980}};

Array Operations Array.Sort(numArray); // sort ascending // Sort begins at element 4 and sorts 10 elements Array.Sort(numArray, 4,10); // Use one array as a key and sort two arrays string[] values = {"Cary", "Gary", "Barbara"}; string[] keys = {"Grant", "Cooper", "Stanwyck"}; Array.Sort(keys, values); // Clear elements in array (array, 1st element, # elements) Array.Clear(numArray, 0, numArray.Length); // Copy elements from one array to another Array.Copy(src, target, numelements);

3. String Operations

Method Compare

Description pare(stra, strb, case, ci)

bool case ? true for case insensitive ci ? new CultureInfo("en-US") returns: ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download