public static void Main() { Console.WriteLine("---Examples of method GetFileExtension from static class FileUtils---"); Console.WriteLine(FileUtils.GetFileExtension("example")); Console.WriteLine(FileUtils.GetFileExtension("example.pdf")); Console.WriteLine(FileUtils.GetFileExtension("example.new.pdf")); Console.WriteLine(); Console.WriteLine("---Examples of method GetFileNameWithoutExtension from static class FileUtils---"); Console.WriteLine(FileUtils.GetFileNameWithoutExtension("example")); Console.WriteLine(FileUtils.GetFileNameWithoutExtension("example.pdf")); Console.WriteLine(FileUtils.GetFileNameWithoutExtension("example.new.pdf")); Console.WriteLine(); Console.WriteLine("---Examples of methods CalculateDistance2D and CalculateDistance3D from static class GeometryUtils---"); Console.WriteLine("Distance between points (1, -2) and (3, 4) in the 2D space = {0:f2}", GeometryUtils.CalculateDistance2D(1, -2, 3, 4)); Console.WriteLine("Distance between points (5, 2), (-1, 3) and (-6, 4) in the 3D space = {0:f2}", GeometryUtils.CalculateDistance3D(5, 2, -1, 3, -6, 4)); Console.WriteLine(); Console.WriteLine("---Examples of the methods in the class RectangularCuboid---"); RectangularCuboid rectangularCuboid = new RectangularCuboid(3, 4, 5); Console.WriteLine("Width = {0}\nHeight = {1}\nDepth = {2}", rectangularCuboid.Width, rectangularCuboid.Height, rectangularCuboid.Depth); Console.WriteLine("Volume = {0:f2}", rectangularCuboid.CalculateVolume()); Console.WriteLine("Diagonal XYZ = {0:f2}", rectangularCuboid.CalculateDiagonalXYZ()); Console.WriteLine("Diagonal XY = {0:f2}", rectangularCuboid.CalculateDiagonalXY()); Console.WriteLine("Diagonal XZ = {0:f2}", rectangularCuboid.CalculateDiagonalXZ()); Console.WriteLine("Diagonal YZ = {0:f2}", rectangularCuboid.CalculateDiagonalYZ()); }
static void Main() { try { Console.WriteLine(File.GetExtension("example")); } catch (FormatException ex) { Console.WriteLine(ex.Message); } Console.WriteLine(File.GetExtension("example.pdf")); Console.WriteLine(File.GetExtension("example.new.pdf")); try { Console.WriteLine(File.GetNameWithoutExtension("example")); } catch (FormatException ex) { Console.WriteLine(ex.Message); } Console.WriteLine(File.GetNameWithoutExtension("example.pdf")); Console.WriteLine(File.GetNameWithoutExtension("example.new.pdf")); Console.WriteLine("Distance in the 2D space = {0:f2}", GeometryUtils.CalcDistance2D(1, -2, 3, 4)); Console.WriteLine("Distance in the 3D space = {0:f2}", GeometryUtils.CalcDistance3D(5, 2, -1, 3, -6, 4)); var someContainer = new RectangularCuboid(3, 4, 5); Console.WriteLine("Volume = {0:f2}", someContainer.Volume); Console.WriteLine("Diagonal XYZ = {0:f2}", someContainer.DiagonalXYZ); Console.WriteLine("Diagonal XY = {0:f2}", someContainer.DiagonalXY); Console.WriteLine("Diagonal XZ = {0:f2}", someContainer.DiagonalXZ); Console.WriteLine("Diagonal YZ = {0:f2}", someContainer.DiagonalYZ); //a person who calls this geometry utils should be wise enought to know what //for example DiagonalXYZ means, therefore to call it as diagonal between sides with side lengths Console.WriteLine("Is my static clever GetDiagonalBetweenSides working correctly? You deside!"); Console.WriteLine("{0} == {1} ? What do you think?", someContainer.DiagonalXYZ, RectangularCuboid.GetDiagonalBetweenSides(3, 4, 5)); }
public static void Main() { { Console.WriteLine(FileUtils.GetFileExtension("example")); Console.WriteLine(FileUtils.GetFileExtension("example.pdf")); Console.WriteLine(FileUtils.GetFileExtension("example.new.pdf")); Console.WriteLine(FileUtils.GetFileNameWithoutExtension("example")); Console.WriteLine(FileUtils.GetFileNameWithoutExtension("example.pdf")); Console.WriteLine(FileUtils.GetFileNameWithoutExtension("example.new.pdf")); } { Console.WriteLine("Distance in the 2D space = {0:F2}", GeometryUtils.CalcDistance2D(1, -2, 3, 4)); Console.WriteLine("Distance in the 3D space = {0:F2}", GeometryUtils.CalcDistance3D(5, 2, -1, 3, -6, 4)); } { RectangularCuboid rectangularCuboid = new RectangularCuboid() { Width = 3, Height = 4, Depth = 5 }; Console.WriteLine("Volume = {0:F2}", rectangularCuboid.Volume); Console.WriteLine("Diagonal XY = {0:F2}", rectangularCuboid.CalcDiagonalXY()); Console.WriteLine("Diagonal YZ = {0:F2}", rectangularCuboid.CalcDiagonalYZ()); Console.WriteLine("Diagonal ZX = {0:F2}", rectangularCuboid.CalcDiagonalZX()); Console.WriteLine("Diagonal XYZ = {0:F2}", rectangularCuboid.CalcDiagonalXYZ()); } }
static void Main() { { Console.WriteLine(FileUtils.GetFileExtension("example")); Console.WriteLine(FileUtils.GetFileExtension("example.pdf")); Console.WriteLine(FileUtils.GetFileExtension("example.new.pdf")); Console.WriteLine(FileUtils.GetFileNameWithoutExtension("example")); Console.WriteLine(FileUtils.GetFileNameWithoutExtension("example.pdf")); Console.WriteLine(FileUtils.GetFileNameWithoutExtension("example.new.pdf")); } { Console.WriteLine("Distance in the 2D space = {0:F2}", GeometryUtils.CalcDistance2D(1, -2, 3, 4)); Console.WriteLine("Distance in the 3D space = {0:F2}", GeometryUtils.CalcDistance3D(5, 2, -1, 3, -6, 4)); } { RectangularCuboid rectangularCuboid = new RectangularCuboid() { Width = 3, Height = 4, Depth = 5 }; Console.WriteLine("Volume = {0:F2}", rectangularCuboid.Volume); Console.WriteLine("Diagonal XY = {0:F2}", rectangularCuboid.CalcDiagonalXY()); Console.WriteLine("Diagonal YZ = {0:F2}", rectangularCuboid.CalcDiagonalYZ()); Console.WriteLine("Diagonal ZX = {0:F2}", rectangularCuboid.CalcDiagonalZX()); Console.WriteLine("Diagonal XYZ = {0:F2}", rectangularCuboid.CalcDiagonalXYZ()); } }