Skip to content

Instantly share code, notes, and snippets.

@dimitris-papadimitriou-chr
Created July 10, 2020 03:46
Show Gist options
  • Select an option

  • Save dimitris-papadimitriou-chr/1e8e8a589c72d68b5d00b090bf1eeaba to your computer and use it in GitHub Desktop.

Select an option

Save dimitris-papadimitriou-chr/1e8e8a589c72d68b5d00b090bf1eeaba to your computer and use it in GitHub Desktop.
string GetShapeDescription1(Shape shape)
{
if (shape is Circle)
return $"found a circle with radius {(shape as Circle).Radius}";
if (shape is Rectangle)
return $"Found {(shape as Rectangle).Height }x {(shape as Rectangle).Width} rectangle";
throw new System.Exception(nameof(shape));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment