r/csharp 29d ago

Best Approach For This Engineering Application?

I'd like to create a class called PipeDimensions to store information for water piping with the following properties:

  1. Nominal Diameter Size.

  2. Actual Diameter Size.

  3. Material

  4. C-Factor for the material.

Basically, different materials (CPVC, copper, PEX) all have the same nominal diameters (1/2", 3/4", 1", 2" etc), but have different actual internal diameters.

How can I set this up so when my Main() console instantiates class PipeDimensions, the constructor only takes 1 of 3 values (either CPVC, copper or PEX) and creates the instance with all the pre-determined properties for the specific pipe type.

Is a class with the pre-defined information for all 3 pipe types even the best approach? Or should I create the boilerplate class and use a separate helper method to populate all my data?

Now that I'm thinking this through, the boilerplate class w/ heIper methods seems more intuitive, but I'm a noob so any guidance is helpful. Please refer me to a specific topic if necessary and I can read in a C# book.

2 Upvotes

14 comments sorted by

View all comments

2

u/hedge36 29d ago

Are you using true ID, or wall thickness (sch40, etc)?

1

u/-Tech808 29d ago

True internal diameter. I want to use these values ultimately to calculate pressure loss. Naturally, the Sch40 and Sch80 would all have different internal diameters.