Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are paths represented by strings and not a separate class?

Tags:

c#

In C#, paths are usually represented by a string and then operated upon by static methods from the static Path class. Why isn't there a class like java.nio.file.Path instead? Such a class would naturally handle platform independent path separators for example.

I'm not asking for a library that implements a (non-static) Path class. I'm asking why the standard library has been designed that way.

like image 352
Tobias Brandt Avatar asked Dec 22 '25 17:12

Tobias Brandt


1 Answers

Because they had to make a design choice, and they chose that one. It occurs, though, that lots of java file-related classes (FileReader, FileOutputStream, etc) also use just a string. It is clear, simple, and gets the job done.

For things like path separators: the Path class in .NET has utility methods for that.

like image 162
Marc Gravell Avatar answered Dec 24 '25 05:12

Marc Gravell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!