Hello!.. I am a VB6 programmer and I want to learn basic of C# Programming. So can anyone help me out?..

I just want to learn on "How will I do this in Visual C#"..

this is a sample code from VB6, now, how will I do this in C#?

Sub Routines

Private sub SetValue(ByVal str as String)
'Some statements here...
Call AssignIt("Some String Here")
End Sub


Public Function AssignIt(ByVal str as string) as String
'Some statements here..
AssigntIt = str
End Sub

Can anyone help me...

6 Years
Discussion Span
Last Post by jhai_salvador

Well... let's see...


// creates a public procedure named AssignIt which takes an input string and internally refers to it as str as well as having a return property of string (meaning it sends a string result back to it's caller)
public string AssigningIt(string str)
    //Some statements here...
    AssignIt = str; // assigns string value of str to the AssignIt method
    return AssignIt; // returns the current value of AssignIt method to the caller

and the other looks more like a method:

private string assignIt; //creates a private string called assignIt

    public string AssignIt //Defines public method AssignIt
            return assignIt; //set get value to return private string assignIt
            assignIt = value; //uses calling string to assign value to assignIt

However, again, what I just demonstrated is a method, not a subroutine. I've actually never come across the concept of subroutines in C# myself, just methods and functions.

In looking for some more details on subroutines in C# I came across this which might help.

You might also find this reference a help in your attempt to go from VB to C#.

Hope this helps :) Please remember to mark as solved once your question has been resolved.

Edited by Lusiphur: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.