[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Interface Get Property Values

Posted on 2009-12-29
Medium Priority
Last Modified: 2013-11-07
Hello and I am sure I am missing something. I have implemented an interface from third party assembly and I want to know the Interface property values before I either change them or do anything else I just want to know their values. I implemented the interface and did a get on one of the properties but all the values are blank. Am I missing something, do I need reflections to do something like this? Thanks

Question by:Corey_819
LVL 12

Expert Comment

ID: 26142309
You should be able to access the property values defined in the interface assuming the class instance the interface referrs to is initialized and actually has those values set.
Can you paste some code in so we can work with it? :)

Author Comment

ID: 26142353
I thought so as well okay here you go I really must be missing something.
 class Program : IComUserIdentity
        static void Main(string[] args)
                IComUserIdentity SCMUser = new Program();
                System.Console.WriteLine("User Name: " + SCMUser.Context);


 private String m_Context;
        private int m_DirType;
        String IComUserIdentity.Context
            get { return m_Context; }
            set { m_Context = value; }


        int IComUserIdentity.DirType
            get { return m_DirType; }
            set { m_DirType = value; }

Open in new window


Expert Comment

ID: 26142458
have you set a debug.breakpoint on each of the properties, and added a watch for each of the properties, so that you can see their default values at run time?

based purely on the datatypes the
String IComUserIdentity.Context should default to null or string.Empty and the
int IComUserIdentity.DirType should default to 0

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Author Comment

ID: 26142531
Tarigpahmed and yeah based on the dataTypes this is excatly what keeps returning as values.
so, I am assuming that these values are not being set during the Third Party Class or app. I will put on the breakpoints and watch the values during runtime and find out if these values are event being populated.

Accepted Solution

tariqpahmed earned 500 total points
ID: 26142589
just fyi... an Interface by design can not set any default values... and relies on you to do all the setting... so the DataType defaults should be the only thing you have to deal with.

With an "abstract" class, the third party API could have set default values, but not with an "Interface"... Interfaces only ensure that any instances of an object have a pre-determined interface.

Expert Comment

by:Ignacio Soler Garcia
ID: 26143884
Implementing the IComUserIdentity does nothing with the properties values. The typical usage would be to pass an instance of the class Program to someone that know how to handle IComUserIdentity.

Your class just create two variables (m_Context and m_DirType) and never assign a value to them so you will always get Nothing and 0.

As I said, implementing IComUserIdentity will never put a value on those variables (how would it be?)

Feel free to ask more if you need.

Author Closing Comment

ID: 31671018
Thank you this makes sense.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month18 days, 23 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question