473,439 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,439 software developers and data experts.

Convert Delphi to C#

hi, i am very new in C#.

How to do this in C#:

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# ?
Nov 17 '05 #1
6 2786
Kostya,

I've never used Delphi, but it looks like you would use:

string test(string param)
{
return null;
}

There is a "return null" in there because you need to return something.
Also, I don't know what the default is for passing parameters in Delphi (is
param passed by value, or by reference?), but the C# code is passing the
string reference by value.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kostya Ergin" <ko****@erginsoft.com> wrote in message
news:OA*************@tk2msftngp13.phx.gbl...
hi, i am very new in C#.

How to do this in C#:

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# ?

Nov 17 '05 #2
string test(string param)
{
return param; // or whatever result
}

C# Programmer's Reference:

http://msdn.microsoft.com/library/en...asp?frame=true
--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Kostya Ergin" <ko****@erginsoft.com> escribió en el mensaje
news:OA*************@tk2msftngp13.phx.gbl...
hi, i am very new in C#.

How to do this in C#:

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# ?

Nov 17 '05 #3
Yes, this that, that works, thanks!

"Carlos J. Quintero [.NET MVP]" <ca*****@NOSPAMsogecable.com> wrote in
message news:OO**************@tk2msftngp13.phx.gbl...
string test(string param)
{
return param; // or whatever result
}

C# Programmer's Reference:

http://msdn.microsoft.com/library/en...tutorials.asp?
frame=true

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Kostya Ergin" <ko****@erginsoft.com> escribió en el mensaje
news:OA*************@tk2msftngp13.phx.gbl...
hi, i am very new in C#.

How to do this in C#:

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# ?


Nov 17 '05 #4
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uJ**************@TK2MSFTNGP12.phx.gbl...
Kostya,

I've never used Delphi, but it looks like you would use:

string test(string param)
{
return null;
}

There is a "return null" in there because you need to return something. Also, I don't know what the default is for passing parameters in Delphi (is param passed by value, or by reference?), but the C# code is passing the
string reference by value.

value or reference, in any way.
Hope this helps.
thanks


--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kostya Ergin" <ko****@erginsoft.com> wrote in message
news:OA*************@tk2msftngp13.phx.gbl...
hi, i am very new in C#.

How to do this in C#:

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# ?


Nov 17 '05 #5
Kostya Ergin <ko****@erginsoft.com> wrote:
There is a "return null" in there because you need to return
something.
Also, I don't know what the default is for passing parameters in Delphi
(is param passed by value, or by reference?), but the C# code is passing
the string reference by value.


value or reference, in any way.


I'm not entirely sure what you were trying to say - Nicholas was
exactly correct, the string reference is passed by value.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #6
Kostya Ergin <ko****@erginsoft.com> 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;
Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
0
by: W. D. | last post by:
Hi Folks, My Delphi is rusty, and my C is corroded. Am I understanding this properly? CPP Code: TMainForm *MainForm Is this a declaration for a form named 'MainForm'
2
by: Peter Williams | last post by:
Hi All, I need to port the following (small) C language function to Delphi: double Rand(void) { return rand()/(1.0 + (double)RAND_MAX); } NB -- elsewhere in the program randomize is called...
2
by: Mel WEaver | last post by:
Hello, I have the following delphi structure for a binary file. I'm looking for idea how to read this file. Mel type TMenuDataStruct = packed record exename : string;
11
by: Kai Bohli | last post by:
Hi all ! I need to translate a string to Ascii and return a string again. The code below dosen't work for Ascii (Superset) codes above 127. Any help are greatly appreciated. protected...
2
by: Mel Weaver | last post by:
Hello, I'm trying to convert these to functions to c# const C1 = 52845; C2 = 22719; function Encrypt(const S: String; Key: Word): String; var I: byte;
8
by: mesutalturk | last post by:
How do i convert the following C# code to Delphi? public static uint GenerateSiteID(string SiteName) { uint id = 0; char arr = SiteName.ToCharArray(); //Convert the sitename to a Char Array...
52
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?...
2
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.