GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  C#
Go To First  |  Previous Question  |  Next Question 
 C#  |  Question 343 of 436    Print  
How can objects be late bound in .NET?

  
Total Answers and Comments: 3 Last Update: June 12, 2006     Asked by: faheemlari 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
May 29, 2006 02:48:44   #1  
Ashishtandon.e Member Since: March 2006   Contribution: 14    

RE: How can objects be late bound in .NET?
instead of using new keyword we can use create object like in this example we are creating object to write in excel sheet through our programexampleImports Excel Microsoft.Office.Interop.ExcelPrivate Sub Button1_Click(ByVal sender As System.Object ByVal e As System.EventArgs) Handles Button1.Click Dim objApp As Object Dim objBook As Object Dim objBooks As Object Dim objSheets As Object Dim objSheet As Object Dim range As Object ' Instantiate Excel and start a new workbook. objApp CreateObject( Excel.Application ) objBooks objApp.Workbooks objBook objBooks.Add objSheets objBook.Worksheets objSheet objSheets.Item(1) range objSheet.Range( A1 ) 'Set the range value. range.Value Hello World! 'Return control of Excel to the user. objApp.Visible True objApp.UserControl TrueEnd Sub
 
Is this answer useful? Yes | No
June 07, 2006 16:05:02   #2  
dotnetrocks        

RE: How can objects be late bound in .NET?
Hi Sometimes it happens that the client does not have an idea of creating an object of which class. it has to be decided at runtime. For such condition reflection can be used to get the type information of the class. Then we can use the Activator.createinstance class in order to create the instance of the object.
 
Is this answer useful? Yes | No
June 12, 2006 14:22:33   #3  
rich        

RE: How can objects be late bound in .NET?
Objects are generally late bound when using class factories with interfaces (or base classes). An example of late binding can be seen below. The function that generates the concrete object (at runtime) will decide which type of concrete object to instantiateIReader reader GetFileOrDBReader();
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape