Re: Convert Delphi to C#



Kostya Ergin <kostya@xxxxxxxxxxxxx> wrote:

> This is function:
> function test(param: string): string;
> begin
> end;
>
> I can get result of "test" function:
> result := test(param);
>
> And how to do in C# ?

The closest you can get to a Delphi function in C# would be a non-void
static method:

static string test(string param) {
// this won't compile since this method is non-void and no value is
// returned, and that's not valid C#
}

FWIW, C# static methods are pretty much the same as Delphi class methods.
Therefore, the above is pretty much the same as:

class function InsertClassNameHere.test(param: string): string;
begin
end;
.



Relevant Pages

  • Re: OO conventions
    ... subclass object (likely by passing a string to the constructor, e.g., ... Image.opendefined as a static method (wait...is that ...
    (comp.lang.python)
  • Re: Can i pass a SqlConnection object with opened connection to a method/function as a parameter?
    ... methods in your long concatenated string, ... DataTools.EscapeMask method (a static method, apparently), or the ... > connection and what you do with it when you get it ... >> the existed opened sqlconnection object to do it and pass the object to ...
    (microsoft.public.dotnet.framework)
  • Re: Accessing functions defined in Global.asax
    ... Anjali Lourda wrote: ... > public function getNameas String ... better off creating a class with a static method and referencing the ... Ryan Walberg, B.Sc., MCSD, MCSD for .NET ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Java syntax extension proposal
    ... You can already reference a static method through an instance, but most sources I've read regard that as a bad practice. ... It allows a static method from one class be called on an instance variable of another class (Let's say String). ...
    (comp.lang.java.advocacy)
  • Re: Inheritable Static methods
    ... Any static method, ... classname to a string, without hardcoding a string. ... encapsulate it into the class itself, so that instead of having the ... the former encapsulates the conversion into the int type. ...
    (microsoft.public.dotnet.languages.csharp)