Skip to content

Instantly share code, notes, and snippets.

@BanksySan
BanksySan / Program.cs
Last active May 5, 2020 19:31
Blog: Public Consts Are Bad (5)
using static System.Console;
using System;
public static class Constants
{
private const double PI = 3.14;
public static double PI_1 = PI;
public static readonly double PI_2 = PI;
public static double PI_3 {get;} = PI;
public static double PI_4 = PI;
@BanksySan
BanksySan / Program.cs
Created May 5, 2020 19:24
Blog: Public Consts Are Bad (4)
using static System.Console;
using System;
public class Constants
{
public const double PI = 3.1415;
}
public static class Program
{
@BanksySan
BanksySan / Program.cs
Created May 5, 2020 19:21
Blog: Public Consts Are Bad (3)
using static System.Console;
public static class Program
{
private static void Main()
{
WriteLine($"π = {Constants.PI}");
}
}
@BanksySan
BanksySan / Program.cs
Created May 5, 2020 19:17
Blog: Public Consts Are Bad (2)
using static System.Console;
using System;
public class Constants
{
public const double PI = Math.PI;
}
public static class Program
{
@BanksySan
BanksySan / NotUsingConsts.cs
Created May 5, 2020 19:12
Blog: Public Consts Are Bad
WriteLine("Hello World!");
WriteLine("Hello World!");
@BanksySan
BanksySan / DrawBoundingBox.cs
Created April 25, 2020 11:56
Blog: Draw Bounding Box
using UnityEngine;
using static UnityEditor.Handles;
using static UnityEngine.Color;
using static UnityEngine.Gizmos;
[ExecuteAlways]
[RequireComponent(typeof(Renderer))]
public class MarkCenterAndExtents : MonoBehaviour
{
private const float RADIUS = 0.02f;
@BanksySan
BanksySan / manifest.json
Last active April 24, 2020 20:51
Unity Manifest
{
"dependencies": {
"com.unity.2d.animation": "3.2.1",
"com.unity.2d.pixel-perfect": "2.0.4",
"com.unity.2d.sprite": "1.0.0",
"com.unity.2d.spriteshape": "3.0.10",
"com.unity.2d.tilemap": "1.0.0",
"com.unity.cinemachine": "2.5.0",
"com.unity.ide.rider": "1.1.4",
"com.unity.progrids": "3.0.3-preview.6",
@BanksySan
BanksySan / MarkCenterAndExtents.cs
Last active April 22, 2020 21:10
Blog - Mark Center andExtents
using UnityEngine;
using static UnityEditor.Handles;
using static UnityEngine.Color;
using static UnityEngine.Gizmos;
[ExecuteAlways]
[RequireComponent(typeof(Renderer))]
public class MarkCenterAndExtents : MonoBehaviour
{
private const float RADIUS = 0.02f;
@BanksySan
BanksySan / Explicit.il
Created April 19, 2020 10:12
Explicit v Implicit IL
IL_0000: ldarg.0
IL_0001: ldfld class BanksySan.Blog.Performance.Child BanksySan.Blog.Performance.Casting::_child
IL_0006: castclass BanksySan.Blog.Performance.Parent
IL_000b: ret
public class Casting
{
private Child _child;
private Parent _parent;
[GlobalSetup]
public void GlobalSetup()
{
_parent = new Parent();