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

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

Hide member in derived class

Posted By:      Posted Date: September 09, 2010    Points: 0   Category :ASP.Net
Hello, I have class with public event:public class MessageCutter    {        public event EventHandler<MessageEventArgs> MessageFound;        ....    }But I don't want derived classes to have this event. Tried with keyword "new", but it does not work:public class Class2:MessageCutter     {         private new event EventHandler<MessageEventArgs> MessageFound;         ....     }If there any way I can do this?

View Complete Post

More Related Resource Links

Derived class and try call private/protected base member


Hi, i often write a class derived from built in .NET class.

Unfortunately, there are many methods/properties/fields that marked private/internal (i decompile using net reflector),
so i call the members using reflection (get method/field/property, invoke method).

The reflection is damn slow!

Anyone knows how to solve my problem? Or have alternate method instead of using reflection?


*** the sealed, internal, and private keywords is enemy for me, it prevents the developer for derivering a class/type.

Class member autocomplete


Is there in C# such feature as in VB when you create some class which inherits some interface and after clicking Enter after line Inherits SomeInterfaceHere all properties and functions which you need to inherit appear?

LINQ to SQL compiler error CS1519: Invalid token 'void' in class, struct, or interface member decl

I get the following compiler errors when creating my first LINQ to SQL class (I just dragged a table "ProfileExtended" onto the designer and hit build):DataClasses.designer.cs(31,11): error CS1519: Invalid token 'void' in class, struct, or interface member declaration these are the offending lines of autogenerated code:#region Extensibility Method Definitions  partial void OnCreated();  partial void InsertProfileExtended(ProfileExtended instance);  partial void UpdateProfileExtended(ProfileExtended instance);  partial void DeleteProfileExtended(ProfileExtended instance);  #endregion

Can you Serialize a Derived class, cast as it's base?

Can you Serialize a Derived class, cast as it's base? (Using the stock XmlSerializer.Serialize?)   (The overall goal I'm trying to achieve, is I have 1 object, and I need to serialize it in 2 different ways, 1 with full info, one with half info, and I *thought* a base class would be the way to do it)   e.g. I have a base and derived class   [XmlRoot("MyBaseXml" )] public class MyBaseClass { public string baseField = "base" ; } [XmlRoot("MyDerivedXml" )] public class MyDerviedClass : MyBaseClass { public string derivedField = "derived" ; }   I make a new instance of my derived class MyDerviedClass obj = new MyDerivedClass();   And then I have the following serialization method(s)   /// <summary> /// Saves an object to a file /// </summary> /// <param name="obj"> Object to save</param> /// <param name="fileName"> Path to output to</param> public void Serialize(object obj, string fileName) { Type type = obj.GetType(); XmlSerializer xmlSerializer = new XmlSerializer(type); Serialize(obj, fileName, type); } /// <summary> /// Saves an object to a file casting it as a specific type /// </summary> /// <param name="obj"> Object to save</param> /// <param name="fileName"

Sharing of Non-Static member variables of a class using .NET Remoting

This kind of weird. I am trying to host an object of a class X (a class library class). This is a SAO and I have set the WellKnownMode as Singleton in the server configuration. <wellknown mode="Singleton" When multiple clients fetch the instance of the class X they can share the static member variables. Any changes made to the static variables are visible to each other. The problem is with the non-static member variables of the class. Each instance is having a local copy of the non-static variables. Why should that happen in case of a Singleton mode? Am I missing something for which this is happening? Any help will be appreciated.  A for apple, B for boy, C for c++

Is it possible to get a base class by it's member?

I.e. I've got my class that contains a Panel. I do dragdrop with that panel, so when i get an form.dragdrop event I'm getting my Panel in eventArgs. I want to get the base class (MyClass), that contain that Panel to invoke some methods. Smth. like GetParent Class... Could you tell, is it possible?

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

Intellisense / class reference not working in MembershipProvider derived class file in App_Code fold



I am new to ASP.NET and may be biting off more than I can chew, but I figure if I jump in the deep end I may learn more.

Can somebody tell me why the Visual Studio intellisense is not working in a newly created class file inside the App_Code folder?

I presume that System.Web is not being referenced from the App_Code folder correctly for some reason, because as soon as I type "using System.Web", everything is fine and then stops when I want to add ".Security" (no dropdown). I think this has an influence on the fact that the inherited MembershipProvider in my code is not highlighted/referenced and I cannot use the "Implement Abstract Class" option.

If I create a new class file in the root folder of my website, everything works fine. I have even tried to delete and recreate the file in my App_Code and it still did not work. I also tried to copy the file from my App_Code folder to the root and it still did not work. My code is as follows:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;

namespace PodcastManager
    public class

Resolving Virtual funtions in derived class


Say I have the following classes:


    class A


        public virtual void fn()


            Console.WriteLine("this is A");




    class B:A


        public virtual void fn()


            Console.WriteLine("this is B");





    class C : B


        public override void fn()


            Console.WriteLine("this is C");




When I say A a = new C() and call a.fn() the class A's version of fn() is called. How is it linking to A's fn()


Urgent: AssemblyName of Class derived from Custom HTTPHandler


Hi everyone,

I have developed a custom http handler which calls a WCF service from within. However the parameters to be passed to the service would vary from request to request.

The parameters could be collected by firing an event. The developer can write an eventhandler for the event which will collect the parameters from any where as required and put it into a property exposed by handler.

This event handler could be written on a .cs page which inherits from the original handler.

When request for the page comes to the custom HTTPHandlerFactory I have created, it should create an instance of child class (of custom HTTPHandler) instead of the actual handler class. However, I only have the Type name of child class. The assembly name in which the type is, is not known as the assembly names keep changing.

I wanted to create an instance of the child class (of custom HTTPHandler ) in Handler factory through reflection and pass it on for processing. But the name of its assembly is not known. Is there a way out?

Thanks in Advance,



How to visist the method or member of service class?


i have a service interface such as IPublishService(PublishService), and i run the service like below:

Uri publishAddress = new Uri("net.tcp://localhost:8004/QTAServer");
publishHost = new ServiceHost(typeof(PublishService), publishAddress);

suppose the pulishservice has a public member news, how can i visit the news memeber in the server client, i have tried method like below:

PublishService ps = publishHost.SingletonInstance as PublishService;


but it is wrong, why is my method not correct?  is there any other method?

Hide a calculated member output based on condition


Hello:  New to SSAS.   Is it easy to alter this caluculated MDX to HIDE or not make visibile the output(Average_Response) if Respondents are < 10? 

However, I only want to Hide the value.   It still needs to be used for aggregate calculations.

Thank you!

CREATE MEMBER CURRENTCUBE.[Measures].Average_Response


AS [Measures].[ResponseGiven]/[Measures].[Respondents],


Hide a repeater in ASP.NET C# if the DataSource contains no items?

I have an ASP.NET page that uses a repeater nested within another repeater to generate a listing of data. It's to the effect of the following:
In the (C#) code-behind I'm basically using LINQ to pull a listing of information from an XML document and bind that information to the first repeater.

Searching for the answer to this, it seems the method is to determine whether the data for the nested repeater is empty. If it is, then you set the visibility of the repeater to false.

Class Diagrams

Class diagrams show the static structure of the systems. Classes define the properties of the objects which belong to them. These include:

Attributes - (second container) the data properties of the classes including type, default value and constraints.

Creating a Simple Class in C#

The second article in the C# Object-Oriented Programming tutorial describes how classes are created in C# and how behaviour, in the form of publicly visible and private, hidden methods can be added. This demonstrates some of the uses of encapsulation

Static Class for Beginners

In general, the members of a class can be accessed by instance of that class when they are in public, but there comes a situation to access or call members of a class without an instance and this can be achieved by declaring them as static

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.
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