cano63
asked on
C# function
Hi, I,m trying to create a function in a module and call it from any form of my program.
I just found that in C# 2003 there is no module. So can any one show me how i,m able to do this in c #.
I put a simple function in vb.net that is call from a form. how i convert this to c#
Also, i would like not use any class.
I just found that in C# 2003 there is no module. So can any one show me how i,m able to do this in c #.
I put a simple function in vb.net that is call from a form. how i convert this to c#
Also, i would like not use any class.
'this is my module '
Public function FullName as string (byval Fname, Lname as string)
FullName = Fname &" " & Lname
end function
'this is the code in the form that call the module that have the function
Load form
label1.text = FullName(Petter, henrick)
end sub
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
What about the Module in c# ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or in the class
this.Load += new System.EventHandler(this.F ormName_Lo ad);
void FormName_load(object sender, EventArgs e)
{
label1.Text = FullName("Petter, "henrick);
}
this.Load += new System.EventHandler(this.F
void FormName_load(object sender, EventArgs e)
{
label1.Text = FullName("Petter, "henrick);
}
you don't have modules in c#
rather create a class and then create function inside it
rest it depends on your implementation you require it to b a static class or normal
in above case you can create a static class
rather create a class and then create function inside it
rest it depends on your implementation you require it to b a static class or normal
in above case you can create a static class
you don't necessarily need a module...you could use a static class, a struct...there are many options...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi
Please try this:
then from any form in your app call :
string displayName = MyStaticFunctions.FullName ;
Please try this:
then from any form in your app call :
string displayName = MyStaticFunctions.FullName
public static class MyStaticFunctions
{
public static string FullName
{
get
{
return Fname + " " + Lname
}
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
again, with your specs of not wanting to use a class, you would use a struct...
see link:
http://msdn.microsoft.com/en-us/library/aa288471%28VS.71%29.aspx
see link:
http://msdn.microsoft.com/en-us/library/aa288471%28VS.71%29.aspx
Also, i would like not use any class.<----author's comment
again, with your specs of not wanting to use a class, you would use a struct...
see link:
http://msdn.microsoft.com/en-us/library/aa288471%28VS.71%29.aspx
the struct would include the method public string FullName that we all know how to create and there you have it...
again, with your specs of not wanting to use a class, you would use a struct...
see link:
http://msdn.microsoft.com/en-us/library/aa288471%28VS.71%29.aspx
the struct would include the method public string FullName that we all know how to create and there you have it...
ASKER
All the Question were good and help me a lot in diferent ways
http://www.developerfusion.com/tools/convert/vb-to-csharp/