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

Function

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

Can anyone help me...

Well... let's see...

Function:

// 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
    {
        get
        {
            return assignIt; //set get value to return private string assignIt
        }
        set
        {
            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.

wow.. thank you.. you solve it..

I'll be back for the part 2 next time. Thanks..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.