C# Snippet – cast

One of my major sources of errors in my home game project are integer math issues. Where adding two bytes gets automatically promoted to an int.

Here is my snippet I wrote to quickly cast the issues away. I sort the error to get the cast error messages, double click to get the code highlighted, right click -> Surround With… -> cast. The default type is byte.

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
      <Description>surrounds selection with cast</Description>
      <Author>Simeon Pilgrim</Author>
      <Code Language="csharp">
        <![CDATA[($casttype$)($selected$ )]]>