C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

Explain code


Posted Date: 07 Nov 2009      Posted By: magda refaat      Member Level: Bronze     Points: 1   Responses: 2



I need explain for this function I know what it do but I want to know how it work .

Private Function DynamicallyLoadedObject(ByVal objectName As String,
Optional ByVal args() As Object = Nothing) As Form
Dim returnObj As Object = Nothing
Dim Type As Type = Assembly.GetExecutingAssembly().GetType(
"[YOUR PROJECT NAME]." & objectName)
If Type IsNot Nothing Then
returnObj = Activator.CreateInstance(Type, args)
End If
Return returnObj
End Function


thaks alot





Responses

Author: Hari    07 Nov 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi,

Assembly.GetExecutingAssembly().GetType(
"[YOUR PROJECT NAME]." & objectName)
The above line searches in the assembly manifest for the type specfied by objectName and returns that type.

returnObj = Activator.CreateInstance(Type, args

Teh above line calls the constructor of the specfied type by passing the arugments if required for the type and returns an instance of the type.



Author: ABitSmart    07 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

The above code is using Reflection to dynamically create a type based on the given object name. Using reflection, given a type it creates an instance object. The above code extracts the type information from the assembly metadata and then creates and instance of the object/

Kind regards,
ABitSmart
DNS Web-master, DNS MVM
My blog
Thoughts.exe



Post Reply
You must Sign In to post a response.
Next : Drag n drop the product in shopping cart
Previous : Tool Tip
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use