is there an object representation of System that i can Extend upon such that the extended method becomes global.
Code:<Runtime.CompilerServices.Extension()> Public sub globalprocedure(ByVal asystem As ?)
Printable View
is there an object representation of System that i can Extend upon such that the extended method becomes global.
Code:<Runtime.CompilerServices.Extension()> Public sub globalprocedure(ByVal asystem As ?)
Do you know what System is? It's a namespace. Objects are instances of type. A namespace and a type are two very different things. A namespace cannot be instantiated, and therefore cannot be extended.
i want to create a function like Mid() Rate() MsgBox() Val() that you can access directly instead of making it a method belonging to a class. is there a way to do it?
btw does these functions all belong to the System Namespace?
1) You shouldn't be using functions like Mid, Rate, MsgBox, or Val because they are VB6 legacy functions. Use the .NET equivalents.
2) If you want to make functions like this, you would place them inside a module.
3)
No, and for questions like this, the easiest way to find out where they are from is by typing in the function in the IDE, right-clicking on it and clicking "Go To Definition", or, press F2 to see the Object Browser and type in the function name and search. You will see that these functions are contained in different modules under the same namespace.Quote:
btw does these functions all belong to the System Namespace?
Under the Microsoft.VisualBasic namespace:
MsgBox is apart of the Interaction module.
Rate is apart of the Financial module.
Val is apart of the Conversion module.
Mid is apart of the Strings module.