\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{VoltaicGRiD (VoltaicGRiD)} \pdfinfo{ /Title (c-net-introduction.pdf) /Creator (Cheatography) /Author (VoltaicGRiD (VoltaicGRiD)) /Subject (C\# / .NET Introduction Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{E3A730} \definecolor{LightBackground}{HTML}{FDF9F2} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{C\# / .NET Introduction Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{VoltaicGRiD (VoltaicGRiD)} via \textcolor{DarkBackground}{\uline{cheatography.com/164411/cs/34452/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}VoltaicGRiD (VoltaicGRiD) \\ \uline{cheatography.com/voltaicgrid} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 7th October, 2022.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Whats What}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Class}} & A class can contain zero or more methods, zero or more constructors, and zero or more variables \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} {\bf{Method}} & A method declares, simply, an action and, if necessary, response in the form of a 'return'. Methods can take variables as arguments to pass data along \tn % Row Count 12 (+ 7) % Row 2 \SetRowColor{LightBackground} \{\{noshy\}\}{\bf{Constructor}} & A method that auto-executes upon the creation of a new instance of a class \tn % Row Count 16 (+ 4) % Row 3 \SetRowColor{white} {\bf{Return}} & The "output" variable of a method used to return data to the method's caller \tn % Row Count 20 (+ 4) % Row 4 \SetRowColor{LightBackground} {\bf{Argument}} / {\bf{Parameter}} & An "input" variable for a method used when calling said method to pass data to it \tn % Row Count 24 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Good Beginner Projects}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Chess Game}} - Create a game of chess with a UI (WPF / WinForms) and utilizing icons from \{\{link="https://fontawesome.com"\}\}FontAwesome\{\{/link\}\} that can be played between two players \newline % Row Count 4 (+ 4) {\bf{Calculator}} - Create a calculator with a UI (WPF / WinForms) that can be used to perform basic mathematical operations on two numbers (addition, subtraction, multiplication, division, square root, exponents) \newline % Row Count 9 (+ 5) {\bf{To-Do List}} - Create a simple UI (WPF / WinForms) where to-do items can be created, and marked off. Marked off to-do's should be retrievable after marked as complete \newline % Row Count 13 (+ 4) {\bf{Weight Conversion Tool}} - A simple console or UI application where a weight type (lbs, kgs, oz) can be converted to any other weight type \newline % Row Count 16 (+ 3) {\bf{Single-page Website}} - Utilize ASP.NET and the options presented when creating a new project to build a single-page website for yourself% Row Count 19 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Diagnosing Exceptions (A.K.A. Runtime Errors)}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Error Message}} & {\bf{Most Likely Cause}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \{\{noshy\}\}`NullReferenceException` & A variable or method is referencing a variable or method that doesn't exist or has been disposed of \tn % Row Count 7 (+ 5) % Row 2 \SetRowColor{LightBackground} \{\{noshy\}\}`StackOverflowException` & Most often caused by too many consecutive method calls \tn % Row Count 10 (+ 3) % Row 3 \SetRowColor{white} \{\{noshy\}\}`IndexOutOfRangeException` & Caused by an attempt to access (read/write) to an array object that doesn't yet exist, or is outside the min/max bounds of the array or list \tn % Row Count 17 (+ 7) % Row 4 \SetRowColor{LightBackground} \{\{noshy\}\}`ArithmeticException` & A failure to cast, convert, or apply arithmetic (mathematical) operations on one or more variables \tn % Row Count 22 (+ 5) % Row 5 \SetRowColor{white} \{\{noshy\}\}`NotFiniteNumberException` & When a floating-point (float) variable reaches positive or negative infinity \tn % Row Count 26 (+ 4) % Row 6 \SetRowColor{LightBackground} \{\{noshy\}\}`IO.IOException` & A failure most often caused by an inability to read or write to a file or folder (either because of permissions, or a locked file) \tn % Row Count 33 (+ 7) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Diagnosing Exceptions (A.K.A. Runtime Errors) (cont)}} \tn % Row 7 \SetRowColor{LightBackground} \{\{noshy\}\}`IO.FileNotFoundException` & Program is unable to find the file in question, and cannot perform any operation going forward \tn % Row Count 5 (+ 5) % Row 8 \SetRowColor{white} \{\{noshy\}\}`IO.DirectoryNotFoundException` & Same as above, except in reference to a folder or directory \tn % Row Count 8 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Object Types}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{int}} - Integer & {\bf{double}} - Floating binary-point number (exact) \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{float}} - Floating binary-point number (estimate) & {\bf{decimal}} - Decimal number (exact) \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} {\bf{string}} - Char array & {\bf{char}} - Character \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} {\bf{bool}} - True/false boolean & {\bf{var}} - Dynamic variable \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Using Statements}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Using statements are declarations of which code libraries are being utilized within this file / class. Additionally, if declared similarly to a variable, a shortened keyword can be used in place of a full-length declaration further within the code. \newline % Row Count 5 (+ 5) For example: \newline % Row Count 6 (+ 1) `using System;` \newline % Row Count 7 (+ 1) `using System.Diagnostics;` \newline % Row Count 8 (+ 1) `using System.Windows.Forms;` \newline % Row Count 9 (+ 1) `using Excel = \seqsplit{Microsoft.Office.Interop.Excel;`}% Row Count 10 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Using the Console}} \tn % Row 0 \SetRowColor{LightBackground} \{\{nobreak\}\}`var input = \seqsplit{Console.ReadLine();`} & Gets the last line input to the console and saves it to variable 'input' \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \{\{nobreak\}\}`Console.Write({\emph{\{\{x\}\}}});` & Writes the text-representation of the variable (any) and does not move to the next line \tn % Row Count 9 (+ 5) % Row 2 \SetRowColor{LightBackground} \{\{nobreak\}\}`Console.WriteLine({\emph{\{\{x\}\}}});` & Writes the text-representation of the variable (any) and moves to the next line \tn % Row Count 13 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Use a variable name in place of \{\{x\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.14471 cm} x{3.83229 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Comments}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{//}} & Single-line comment \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{/*}} & Begin multi-line comment \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{*/}} & End multi-line comment \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Declaring a Variable}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Declaring a variable is as easy as knowing the type of variable needed, a name for the variable, and the default (a.k.a. initial) value for said variable. \newline % Row Count 4 (+ 4) `\{Variable Type\} \{Variable Name\} = \{Default / Initial Value\};` \newline % Row Count 6 (+ 2) Say we need to create an integer named "itemCount": \newline % Row Count 8 (+ 2) `int itemCount = 0;` \newline % Row Count 9 (+ 1) Now what about a true/false statement named "validated": \newline % Row Count 11 (+ 2) `bool validated = false;` \newline % Row Count 12 (+ 1) A variable based off a class named "Car" with a variable named "newCar": \newline % Row Count 14 (+ 2) `Car newCar = new Car();`% Row Count 15 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Declaring a Method}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Declaring a method is nearly as simple as declaring a variable, you must know the publicity of the method, the return type (if one is needed), the name of the method, and any arguments (data) that is needed by the method. Remember, you create the name of the method. \newline % Row Count 6 (+ 6) `\{Publicity\} \{Return Type\} \{Method Name\} (\{Arguments\})` \newline % Row Count 8 (+ 2) Lets say we need a public method that returns an integer named "Add" that takes two integers as arguments: \newline % Row Count 11 (+ 3) `public int Add (int number1, int number2)` \newline % Row Count 12 (+ 1) We can also declare a method with an optional parameter by declaring an argument with a default value: \newline % Row Count 15 (+ 3) `public int Add (int number1, int number2, int number3 = 0)` \newline % Row Count 17 (+ 2) Alternatively, we can create methods that don't return anything: \newline % Row Count 19 (+ 2) `public void DoSomething ()`% Row Count 20 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.24425 cm} x{3.73275 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Publicity / Access Modifiers}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{public}} & Accessible from any class within any assembly or namespace \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{internal}} & Accessible from any class within only this assembly \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{protected}} & Accessible only by this class and any class derived or inherited by this class \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} {\bf{private}} & Accessible only by this class \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Access modifiers can be used on Methods, Classes, and even Variables, to allow for granular access to only the necessary aspects of your code. \newline \newline \{\{link="https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers"\}\}Access Modifiers\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Utilizing Git (Building a Portfolio) {\bf{WIP}}}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Firstly, ensure you have a GitHub or other Git application account. Most beginning / solo developers prefer \{\{link="https://github.com"\}\}GitHub\{\{/link\}\} for its ease-of-use and issue tracking capabilities. \newline % Row Count 5 (+ 5) Once an account is created, create a project (a.k.a. repository) and name it appropriately in the application, include as much detail, and a description, as possible. \newline % Row Count 9 (+ 4) From the newly created project's dashboard, look for a button to clone the repository to your machine. A few options may be presented, and if using both Visual Studio and GitHub, the 'Clone to Visual Studio' magnet button is a quick and efficient way of cloning the repository locally.% Row Count 15 (+ 6) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.89586 cm} x{4.08114 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Logical Operators}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{==}} & Equal to \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{!=}} & Not equal to \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{\&\&}} & And (i.e. A == 1 \&\& B == 2) \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} {\bf{||}} & Or (i.e. A == 1 || B == 2) \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} {\bf{\textgreater{}=}} & Greater than or equal to \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} {\bf{\textless{}=}} & Less than or equal to \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} {\bf{\textgreater{}}} & Greater than \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} {\bf{\textless{}}} & Less than \tn % Row Count 8 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}