\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{Calment (Calment)} \pdfinfo{ /Title (visual-c-2008-basic-knowledge-grammar.pdf) /Creator (Cheatography) /Author (Calment (Calment)) /Subject (Visual C\# 2008 - Basic knowledge - Grammar 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}{4169E1} \definecolor{LightBackground}{HTML}{F3F5FD} \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{Visual C\# 2008 - Basic knowledge - Grammar Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Calment (Calment)} via \textcolor{DarkBackground}{\uline{cheatography.com/121924/cs/22493/}}} \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}Calment (Calment) \\ \uline{cheatography.com/calment} \\ \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 15th May, 2020.\\ 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{tabularx}{17.67cm}{x{6.5626 cm} x{10.7074 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Variable declaration}} \tn % Row 0 \SetRowColor{LightBackground} double douNum; & ① Data Type + Variable \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} douNum = 777; & ① Use "=" when substituting a value. \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} string strName = "Test"; & ② Declaration and assignment. \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} int iID = 157, iPW = 653; & ③ ②+④ \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} bool bFlg, bFLG; & ④ If the data types are the same, they can be declared together. \tn % Row Count 10 (+ 3) % Row 5 \SetRowColor{white} bFlg = true; & ⑤ Be case-sensitive. \tn % Row Count 11 (+ 1) % Row 6 \SetRowColor{LightBackground} bFLG = false; & ⑤ Be case-sensitive. \tn % Row Count 12 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{1.647 cm} x{3.1293 cm} x{8.5644 cm} x{3.1293 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{17.67cm}}{\bf\textcolor{white}{Type of data type}} \tn % Row 0 \SetRowColor{LightBackground} sbyte & Signed 8bit & -128\textasciitilde{}127 & \seqsplit{System.SByte} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} byte & \seqsplit{Unsigned} 8bit & 0\textasciitilde{}255 & \seqsplit{System.Byte} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} short & Signed 16bit & -32,768\textasciitilde{}32,767 & \seqsplit{System.Int16} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{ushort} & \seqsplit{Unsigned} 16bit & 0\textasciitilde{}65,535 & \seqsplit{System.UInt16} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} int & Signed 32bit & -2,147,483,648\textasciitilde{}2,147,483,647 & \seqsplit{System.Int32} \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} uint & \seqsplit{Unsigned} 32bit & 0\textasciitilde{}4,294,967,295 & \seqsplit{System.UInt32} \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} long & Signed 64bit & -9,223,372,036,854,775,808\textasciitilde{}9,223,372,036,854,775,807 & \seqsplit{System.Int64} \tn % Row Count 15 (+ 3) % Row 7 \SetRowColor{white} ulong & \seqsplit{Unsigned} 64bit & 0\textasciitilde{}18,446,744,073,709,551,615 & \seqsplit{System.UInt64} \tn % Row Count 17 (+ 2) % Row 8 \SetRowColor{LightBackground} float & 32bit & ±1.5×10(-45)\textasciitilde{}±3.4×10(38) & \seqsplit{System.Single} \tn % Row Count 19 (+ 2) % Row 9 \SetRowColor{white} \seqsplit{double} & 64bit & ±5.0×10(-324)\textasciitilde{}±1.7×10(308) & \seqsplit{System.Double} \tn % Row Count 21 (+ 2) % Row 10 \SetRowColor{LightBackground} \seqsplit{decimal} & 128bit & ±1.0×10(-28)\textasciitilde{}±7.9×10(28) & \seqsplit{System.Decimal} \tn % Row Count 23 (+ 2) % Row 11 \SetRowColor{white} char & 16bit & 0\textasciitilde{}65535 Unicode & \seqsplit{System.Char} \tn % Row Count 25 (+ 2) % Row 12 \SetRowColor{LightBackground} bool & bool type & True or False & \seqsplit{System.Boolean} \tn % Row Count 27 (+ 2) % Row 13 \SetRowColor{white} \seqsplit{string} & string type & 0\textasciitilde{}2 billion this Unicode & \seqsplit{System.String} \tn % Row Count 29 (+ 2) % Row 14 \SetRowColor{LightBackground} \seqsplit{object} & object type & Any type & \seqsplit{System.Object} \tn % Row Count 31 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Variable Scope}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{17.67cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/calment_1587715986_VariableScope.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{3.1086 cm} x{14.1614 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Access modifier type}} \tn % Row 0 \SetRowColor{LightBackground} public & Access from outside is also OK. \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \seqsplit{protected} & Only in Class and from Derived Class. \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{internal} & Only in the same assembly. \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{private} & Only in the class in which it is declared. \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{2.6352 cm} x{6.7527 cm} x{4.1175 cm} x{2.9646 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{17.67cm}}{\bf\textcolor{white}{Literal}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Literal} & Data that directly expresses a value. & Bool Literal & True or False \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \seqsplit{Prefix} & Add to the front. & Char Literal & \seqsplit{Enclose} with ''. \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} \seqsplit{Suffix} & Add to the end. & String Literal & \seqsplit{Enclose} with "". \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{Number} \seqsplit{Literal} & L or l : long & U or u : uint or ulong & UL or ul : ulong \tn % Row Count 12 (+ 3) % Row 4 \SetRowColor{LightBackground} Real \seqsplit{number} & F or f : float & D or d : double & M or m : \seqsplit{decimal} \tn % Row Count 15 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}----} \SetRowColor{LightBackground} \mymulticolumn{4}{x{17.67cm}}{Point : Numerical types other than decimal type are binary numbers. Decimal type is decimal. \newline Perfect accuracy : Decimal, Other than that : double, Memory savings : float} \tn \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{3.7881 cm} x{2.9646 cm} x{3.7881 cm} x{5.9292 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{17.67cm}}{\bf\textcolor{white}{Cast}} \tn % Row 0 \SetRowColor{LightBackground} Implicit type \seqsplit{conversion} & int ➝ double : OK & Explicit type \seqsplit{conversion} & double dNum ➝ int iNum = dNum : OK \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Implicit cast & double ➝ int : NG & Explicit cast & \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} srting strNum ➝ int & \seqsplit{int.Parse(strNum);} & int iNum ➝ string & \seqsplit{iNum.ToString();} \tn % Row Count 9 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}----} \SetRowColor{LightBackground} \mymulticolumn{4}{x{17.67cm}}{Caution : \newline Digit loss (floating point only) \newline Information loss (floating point only) \newline Rounding error (both fixed and floating point) \newline Truncation error (both fixed and floating point)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{4.2175 cm} x{9.1098 cm} x{3.5427 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{Naming convention}} \tn % Row 0 \SetRowColor{LightBackground} Hungarian notation & Data type + word & strName \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Pascal format & Capitalize each word. & \seqsplit{UserName} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Camel format & The initials of the first word are lowercase. The initials of the latter words are capital letters. & \seqsplit{userFirstName} \tn % Row Count 9 (+ 5) % Row 3 \SetRowColor{white} Snake format & Underbar when connecting words. & \seqsplit{user\_first\_name} \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \end{document}