-1

In the Namespace System.IO from mscorlib.dll there is the following field:

public static readonly char DirectorySeparatorChar

According to the documentation, it contains \ on Windows and / on Unix. (http://msdn.microsoft.com/en-us/library/system.io.path.directoryseparatorchar%28v=vs.110%29.aspx)

My Question: Why is this field here? What is the usecase of it?

My assumption was always, that .NET is only supported on the Windows Platform.

Christian Gollhardt
  • 16,510
  • 17
  • 74
  • 111

2 Answers2

3

Some .Net Code (Not all) can be run on Linux Platforms as well using Mono.

A commonly used code block across windows and Linux would be the primary use case for the field in question.

Please take a look at the project documentation from mono and search for DirectorySeperatorChar or scroll down to it!

DL Narasimhan
  • 731
  • 9
  • 25
1

Why is this field here?

To not tie an application to Windows, or rather the \ separator.

What is the usecase of it?

See above.

My assumption was always, that .NET is only supported on the Windows Platform.

The Microsoft .NET Framework is only supported on Windows, yes. The team at some point decided they do want to encourage other implementations of the CLI, possibly running on other operating systems, and adding fields like this only helps that.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272