how to make function dot function

merckrene

Member
Joined
Nov 3, 2009
Messages
9
Programming Experience
Beginner
i want to create a function that can trigger another function by using the "."

example

myclass.function(variable).function()

is anyone know how to make this thing?
 
I think you misunderstand what is happening here...

Dim b = MyClass.MyMethod(variable).ToString()

is the same as

Dim a = MyClass.MyMethod(variable)
Dim b = a.ToString()

MyMethod is a function in your class that returns an object of type X. If you add a period after the method call, you are accessing the methods of the returned object. Thus:

Public Class MyClass
    Public Function MyMethod(ByVal variable As Integer) As MyReturnType
        Return New MyReturnType
    End Function
End Class

Public Class MyReturnType
    Public Function ReturnTypeMethod() As Integer
        ' Do something here and return an integer...
    End Function
End Class

Dim i As Integer = MyClass.MyMethod(variable).ReturnTypeMethod()
 
Let the first function return a value of some type, and implement or extend a function for that type.
aclass.function(variable).function()
You can break that into two statements so it is easy for you to see where the second function must be added:
Dim x As bclass= aclass.function(variable)
x.function()

The type "bclass" in this example is a type (class or structure) that you define and add function to, or an existing type that you can write an extension method for.
 
Back
Top