.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Interface object Versus Class Object

Posted By:      Posted Date: October 10, 2010    Points: 0   Category :ASP.Net

Asslam o Alaikum

namespace Interface
    interface IMyInterface
        void Start();    
        void Stop();

    class Program : IMyInterface
        void IMyInterface.Start()
            Console.WriteLine("\n Void Start Method Implement");
        void IMyInterface.Stop()
            Console.WriteLine("\n Void Stop Method Implement");
        static void Main(string[] args)
            IMyInterface iMyInterface = new Program();

1. IMyInterface iMyInterface = new IMyInterface(); // if i create the object of interface i get Error
2. Program iMyInterface = new Program(); // if i create the object of program i can't get the property of Interfaces i.e. Start(); stop();
3. IMyInterface iMyInterface = new Program(); // This will work fine

i want know the difference about 3 points can any body claer it ..


View Complete Post

More Related Resource Links

Building a Custom Data Grid: Performing Ad Hoc Web Reporting with a VBScript 5.0 Class Object


A flexible, customizable grid for displaying data is a useful tool for ASP developers. It allows Web visitors to customize their view of your data. This article takes the data grid presented in "Ad Hoc Web Reporting with ADO 2.0" by John Papa and Charles Caison (MIND, December 1998) and adds handy features such as a finds feature that supports multiple finds and a mode for adding and editing records. This version also improves response time by allowing asynchronous record download and it componentizes the code so it can be used as a standalone VBScript class object that can be reused in other pages.

Randall Kindig

MSDN Magazine July 2000

send data in class object from one page to another using session


hello everybody

now i hav stored all data like user name, data fatched from database of that user

and i stored that data and user name such as:

string strUserName="user name"

dataset ds =new dataset();// data of that user

now i wan yo send d whole data from my login page to user profile page

can anybody help me for that...................

and plz tell me that how much is this way is benifitial to send data from one page to another page

plz........kindly waiting for positive rply

Calling a method with a class object as parameter data type.

   [WebMethod]    public string GetInfo(Customer inCust)    {        // Code in here    } I have a web service that resides on a remote server. I want to call a public method of theweb service named  "GetInfo". The method is shown above. The web service method expects a class object oftype "Customer". What I did to create a Customer object was to define in my asp.net project my own class named "Customer" which is exactlythe same as the class that belongs to the web service project on the remote server. I then created an instance of Customerand tried to call the web service passing in an object of type customer : my.Service ws = new my.Service(); // Get web service connectionCustomer aCustomer = new Customer();aCustomer.Initialize();ws.GetInfo(aCustomer) // call web service passing in a Customer object The problem is that the compiler gives me the following error: Value of type '_Default.Customer' cannot be converted to 'ws.Class1'. Here Default is refering to my Default.aspx.cs code. Why is this? Do I need to Cast my "aCustomer" class object to a type ofws.Customer ? How do I do that?

Using extensions with Object Class and Page in WPF

I don't usually ask a question without trying it first, but hey, why not.  Searching for this one is not exactly easy. I am wondering if I can use extensions with Object and if they (the variables) will subsequently be available for use in a Page partial class generated for WPF?  By this I mean in the same project and assembly. BTW, I won't be offended by posts pointing out why not to do this with Object.  The why in this case is something as basic as having one base class that contain: bYes = True; bNo = False; Now of course, having a base class is not going to work with something like Page... There may be much better ways to this, what I do not want is syntax MyBaseInstance.bYes and MyBaseInstance.bNo in MyPageInstance and bYes or bNo everywhere else.  Any advice? Regards,  Dave Horsman

Unable to cast COM object of type 'System.__ComObject' to interface type 'IRowset'


Unable to Create Object Variable for Linq Data Class


For some unknown reason I suddenly am unable to create an object variable for a Linq Data Class. If I create a new project and try the process again with the same database everything works as advertized.

The code I am using is Dim db As New RoggDataContext  which gives me an error on the object variable "db": Overload resolution failed because no accessibility 'NEW'  accepts this number of arguments.

I have looked inside every file in the Web Project like the web config to check the connection string, gobal, and designer.vb looking for any errors whit no JOY.  I also tried to create a new form and code behind with a button and received the same error.

This is mind blowing because as I already stated, I can create a new Web Site and the problem goes away.

Any help is appreciated!



Is it possible to cast COM object to the custom interface?


I have following code which succesfully works using some COM wrapper library with all needed managed types for COM objects

mshtml.HTMLDocumentClass doc = (mshtml.HTMLDocumentClass)_webBrowser.Document;

mshtml.HTMLIFrameClass iframe = (doc).getElementById("SomeFrameName") as mshtml.HTMLIFrameClass;

if (string.Equals(iframe.readyState.ToString(), "complete", StringComparison.OrdinalIgnoreCase))


 // Do something


But I need to avoid this COM wrapper Micrososft.mshtml.dll and use custom interfaces for this reason, so please explain me how way can I work with COM objects with custom interfaces? How do I write them and avoid classes mshtml.HTMLDocumentClass and mshtml.HTMLIFrameClass?

How to recognise obsolate object from isolated storage whose class has been changed?

<!-- [if gte mso 10]> <mce:style>


Our company is building a word add-in (document-level add-in) with visual studio 2008, word 2007 and VSTO 3.0 sp1

There is one issue that causes us a headache. It is related to obsolete objects in isolated storage.

In Word add-in we serialize object and save it to isolated storage. Later we can load that object from isolated storage and use it in our application.

The problem occurs in following scenario:

-We are working in Word add-in and save one serialized object to isolated storage

-Turn of Word add-in and change code of the class whose instance we have saved in isolated storage

-Work in word add-in again and load and deserialize object from isolated storage. This object is of obsolete class and code usually breaks here or later in code when we are trying to access changed content.

If this scenario happens, we will clear obsolete object from isolated storage. Issue is how to recognize that object’s class is changed?

We tried to recognize changes in the following ways:

·       &

how to create class and acess member using object

hi i am a new user to C# .net can any body help me to write a new class in c# AND HOW TO ACESS methods and members using its object thnks in advance

Can't call C# object via a COM interface, because its not wrapped by RCW after GetObjectForIUnknown


I am using some code to try and get a handle to the OLE IDropTarget COM interface implementation for a WPF Window, so that I can call interface methods directly. What I expected is that the object is returned as a COM callable runtime wrapper object, and that I could cast it to my own declaration of the IDropTarget interface, see code below:



Window w = Window.GetW

How to update value directly in class Object using Linq



I have a class object which is basically kind of hierarchy and looks like this when I convert that to XML.


  	<SKU>SKU 1</SKU> 
	<ConfigurationStatus>Not Configurable</ConfigurationStatus> 
  			<SKU>SKU 2</SKU> 
  			<ConfigurationStatus>Not Configurable</ConfigurationStatus> 
  					<SKU>SKU 3</SKU> 
		  			<ConfigurationStatus>Not Configurable</ConfigurationStatus> 



So you can see that I have "objectComponent" which is kind of hierarchy and that hierarchy can be upto any level.

Now I need to update <quantity> value where <sk

how to persist a class object when page PostBack


i have created a user control UserControl.ascx, in Code behind file of UserControl.ascx i have created an object of a class MyClass.cs,
if(!Page.IsPostback) {
objMyClass= new MyClass();
but when i click on button of UserControl.ascx page and try to access objMyClass object then it set as null, so how to persist MyClass object when page PostBack, i wanted to keep object persist till the user access the page, when user goes out of this page then object should distroy?

To keep the object persist, i have used ViewState

So i have made MyClass Serializable and
i have used ViewState to keep my objet persist, but it give the error
like : UserControl is not marked as serializable.

so i have made my UserControl as Serializable, but the problem is still coming.

One more thing is that MyClass is also resposnsible to create some other class object also.

Can any one suggest me correct solution?

Problem i am getting when i try to PersisObject On UserControl

[SerializationException: Type 'ASP.common_grid_UserControl_ascx' in Assembly 'App_Web_44142fbl, Version=, Culture=neutral, PublicKeyToken=null' is not marked as serializable.] System.Runtime.Serialization.FormatterServices.InternalGetSeri

How to Bind ExpressionTextBox to my class object in ActivityDesigner?



I am just learning WF so this may be a easy question to answer.

I have a custom code activity, AddJobToQueue that takes as input arguments a MessageQueue and a JobTicket. JobTicket is my custom class from a separate library (added as a Reference).

In trying to create an custom activity designer for my activity, I have hit a snag. My activity designer uses two ExpressionTextBoxes for the two input arguments. I was able to get the binding correct for the MessageQueue, but I cannot determine how to get the binding for my custom class.

My current XAML is this:

<sap:ActivityDesigner x:Class="QueueActivityLibrary.AddJobToQueueDesigner"  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

Inserting Property values of class into ParamArray parameters as object()


Hi All,

Using the properties as defined in a class, how about can I put them into the ParamArray parameters argument of my function.

The code as follows:

Public Class MyObject

   Public Property Prop1 as string

   Public Property Prop2 as integer

   Public Property Prop3 as Boolean

   Public Sub  AddNewMyObject

        MsSQL_ExecuteNonQuery("StoredProc_AddNewMyObject", ________________?)

   End Sub

End Class

Protected Function MsSQL_ExecuteNonQuery(ByVal storedProc as string, ByVal ParamArray parameters as object())

'Some Code here.

End Function

Please kindly help and advice.

Thank you in advance.

Warmest Regards,


Service returning Object fails when object is complex class


Hi. I have created a WPF client and a self-hosted WCF Service based on an interface, in wich alle methods returns a standard response class. An example of one such method definition is:

Response CreateAccount(AccountCreationParams accountParams);


The response object is defined as:



public class Response



public string ResponseText;


public bool CompletedSuccesfully;






I am trying to learn how to pass a JavaScript object to a server side class and have been successful when it is a simple JavaScript object.  

Suppose I have this Person class:

public class Person
  public string FirstName { get; set; }
  public string LastName { get; set; }
  public string Address { get; set; }
  public string City { get; set; }
  public string Zip { get; set; }

And this web service method:

  public void AddPerson(Person NewPerson)

On the client I can create a JavaScript object like the one below and then pass it to the server. On the server side the Person class will have all properties populated by the values in the JavaScript object.

"{"NewPerson":{"FirstName":"Jon","LastName":"Doe","Address":"15 Stanley Road","City":"AnyCity","State":"AnyState","Zip":"55555"}}"

This all works fine and as you can see the JavaScript object and the Person class have no collection (array) properties.  

However, I would like my Person class to have a collection of phone number. So I person could have a home

How to auto-generate object initzializer code according to any given class definition?



I think this is at least somewhat connected to reflection so I posted it here.

I work with WCF and Web Services right now. Of course I use the tools provided to generate code from the WSDL documents, hence, for every datatype, a corresponding class is generated. As the WS has loads of types with nested subtypes, I get about 80 usually small classes, only having a few members. In order to implement all that, I have to initialize the classes over and over again.

So I wonder, if there is no way, to use reflection to automatically generate  code (object inizializer) from the class definition, including all subclasses?

Ideal would be a snipped - so that I just enter the name of any random class and dynamically get the full initializer generated. Do snippets actually have the power to do that?

As this will save a lot of stupid typing, I also wonder, if there aren't already any tools, snippets or widgets that do this? I assumed that is is something many programmers might need, but google did not show anything like it.

Thank you very much!

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend