Pascal => C#

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Hi Guys,

Is there a reference that would help someone coming from Delphi to
find equivalent functions in C#?

I'm currently looking for a C# version of Delphi's
IncludeTrailingPathDelimiter(). This function accepts a string and
returns the string with a trailing path delimiter (/ or \ depending on
platform). If the string already has the trailing delimiter, it is
returned unmodified.

I know I'll run into other translation issues so if anyone could point
me to a good reference, I'd appreciate it.

Thanks,
Steve
 
Steve said:
Hi Guys,

Is there a reference that would help someone coming from Delphi to
find equivalent functions in C#?

I'm currently looking for a C# version of Delphi's
IncludeTrailingPathDelimiter(). This function accepts a string and
returns the string with a trailing path delimiter (/ or \ depending on
platform). If the string already has the trailing delimiter, it is
returned unmodified.

I know I'll run into other translation issues so if anyone could point
me to a good reference, I'd appreciate it.

I'm not sure that specific method exists in C# but it would be simple to
write:

public string IncludeTrailingPathDelimiter(string path)
{
if (path.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
{
return path;
}
else
{
return (path + System.IO.Path.DirectorySeparatorChar);
}
}
 
Steve said:
Is there a reference that would help someone coming from Delphi to
find equivalent functions in C#?

Not that I'm aware of - although Jon Shemitz's book ".NET 2.0 for
Delphi developers" may well be useful to you.
I'm currently looking for a C# version of Delphi's
IncludeTrailingPathDelimiter(). This function accepts a string and
returns the string with a trailing path delimiter (/ or \ depending on
platform). If the string already has the trailing delimiter, it is
returned unmodified.

I know I'll run into other translation issues so if anyone could point
me to a good reference, I'd appreciate it.

If the bigger picture is that you're trying to create a full filename
given a parent directory and the next level (whether that's a file or
another directory name) Path.Combine is your friend.
 
Steve said:
Hi Guys,

Is there a reference that would help someone coming from Delphi to
find equivalent functions in C#?

I'm currently looking for a C# version of Delphi's
IncludeTrailingPathDelimiter(). This function accepts a string and
returns the string with a trailing path delimiter (/ or \ depending on
platform). If the string already has the trailing delimiter, it is
returned unmodified.

I don't think that's a built-in function, but it sounds like about 3 lines
of code...
 
Michael said:
I don't think that's a built-in function, but it sounds like about 3 lines
of code...

A bit of googling indicates that it is part of Delphi starting
from Delphi 7.

But it should be easy to achieve the desired functionality
using the System.IO.Path class.

Arne
 
Steve said:
Hi Guys,

Is there a reference that would help someone coming from Delphi to
find equivalent functions in C#?

I'm currently looking for a C# version of Delphi's
IncludeTrailingPathDelimiter(). This function accepts a string and
returns the string with a trailing path delimiter (/ or \ depending on
platform). If the string already has the trailing delimiter, it is
returned unmodified.
I know I'll run into other translation issues so if anyone could point
me to a good reference, I'd appreciate it.


Maybe this book would be of some use:

..NET 2.0 For Delphi Programmers
http://www.amazon.com/exec/obidos/ASIN/1590593863

but I have to think your ultimate best reference is the .NET Framework Class
Library Reference; you have to learn the FCL anyway
 
Back
Top