Using type object to bind object properties in C#?
I've been coding in c++ for 3-4 years now, but I'm pretty new to C#. Thinking I can pick up quite easily and figure it out for myself with the help of online tutorials, I开发者_Go百科 started working on asp.net/C# projects for my workplace... but C# has so many things that just confound me, I think I'm going to have to go pick up a book and start reading C# fundamentals.
In the meantime, I was hoping to find out the reason behind this statement, because I just simply don't understand it:
/Bind to the native AdsObject to force authentication. entry is type DirectoryEntry/
object obj = entry.NativeObject;
What is the point of doing this? A simple, clear explanation will suffice. Thank you so much.
You are using a 'managed' library (System.DirectoryServices) to utilize the 'DirectoryEntry' class and the likes.
But, in this case, its just a facade over the original "COM" (unmanaged) objects. Sometimes it's desirable to directly talk to the 'old COM object' instead of the 'managed' .Net wrapper class.
the .NativeObject property will have the IUnknown/IDispatch interface pointer to the COM object.
Hope this helps,
精彩评论