Use Derived Class Shared Variables In Shared Methods Of Base Class?

Jun 4, 2010

I am trying to add shared members in derived classes and use that values in base classes...

I have base

class DBLayer
public shared function GetDetail(byval UIN as integer)
dim StrSql = string.format("select * from {0} where uin = {1}", tablename, uin)
end function
end class

[Code]..

currently there is error using the tablename variable of derived class in base class but i want to use it i dun know other techniques if other solutions are better then u can post it or u can say how can i make it work? confused...

View 2 Replies


ADVERTISEMENT

Derived Class Shared Methods?

Nov 3, 2010

I have a function that 2 derived classes use, but the third doesn't, would it make sense to just leave it in the base class, even though one of the 3 derived classes doesn't use it?The only way I could think of disallowing the third class is to basically create an intermediate class that is derived of the base, then the 2 that use the common function are derived off the second class.

Is it possible to prevent the 3rd class from using the function, while letting the two that are supposed to use it, use it?Does that just seem to go overboard, I mean as long as I don't "try" to call the function from the 3rd class, it shouldn't be a problem, I just was interested if there was a way to prevent it all together without a lot of hassle.

View 2 Replies

Can't Inherit Shared Properties From A Base Class In A Child Class?

Dec 29, 2010

This is another one of my "I think it's not possible but I need confirmation" questions.I have a base class for a bunch of child classes. Right now, this base class has a few common properties the children use, like Name. The base is an abstract class (MustInherit)Technically, this means that everytime a child class is instantiated, it lugs around, in memory, its own copy of Name. The thing is, Name is going to be a fixed value for all instances of a given child. I.e., Child1.Name will return "child_object1", and Child2.Name will return "child_object2".

View 1 Replies

Override A Public Shared Method In Derived Class?

Oct 8, 2010

Can we override a Public Shared method in derived class? If not why?

View 2 Replies

Shared Class With Generic Methods?

Jan 28, 2010

I have created a Interface and a couple classes that implement this Interface. I am in the process of developing a Shared Class that utilizes the functions that each of the individual classes have, due to the interface implementation.What i need to know is how do i develop this Shared Class so that way each of the methods within it are restricted to a single data type. This single data type needs to be restricted to any class that has implemented the Interface.

Some examples:

Public Interface IVector(Of T)
Sub Add(ByVal v2 as T)

[code]....

As you can see it would allow me to develop one form, since i have standardized the required Subs/Functions for any class the implements the IVector interface. As i am still in developement, i was wondering if my current understanding of the method generics is correct in its current form or what i would have to do to make the Generic Shared Class work in the fashion that i am looking for in the example implementation.

View 6 Replies

Calling Shared Methods From .NET Class Library In VB6

Jan 25, 2010

I have the following class in a .NET class library:

Code:
Public Class JasonTest
Sub New()
End Sub

[Code]....

The .AddNumbers call works fine, but the AddStrings call yields the error 'Object doesn't support this property or method'.

Is there any way to call a shared method from .NET in VB6? I was unable to find any documentation on this.

View 5 Replies

Purpose Of Using Shared Methods That Return An Instance Of A Class?

Oct 11, 2010

What is the purpose of using shared methods that return an instance of a class, as opposed to a constructor?

ie: in VB.net, the system.drawing.color class has shared method "FromArgb(int, int, int) as color". This is different from java's implementation which simply is a constructor that takes three ints. Why the decision to do one or the other?

View 1 Replies

Will Modifying Shared Methods Change The Class That Reference Them

Jun 4, 2011

I'm wondering what will actually change a class, in the sense that serialized objects of this class will no longer be recognized. If the class has reference to shared methods of another class. Will changing such shared methods also change the classes that reference them?

View 3 Replies

Base Class With Shared Fields And Functions Good Design ?

Apr 22, 2010

I've got a BaseDataClass with shared fields and functions

CODE:

I have several classes that derive from this base class. The derived classes have all Shared functions that can be called directly from the BLL with no instantiation. The functions in these derived classes call the base Init(), call their specific stored procs, call the base CleanAll() and then return the results.

So if I have 5 derived classes with 10 functions each, totaling 50 possible function calls, since they are all Shared, the CLR only calls one at a time, right? All calls are queued to wait until each Shared function completes.

Is there a better design with having Shared functions in your DAL and still have base class functions? Or since I have a base class, is it better to move towards instance methods within the DAL?

View 1 Replies

Mimic An Interface / Contract For Shared Methods In A Class For Use By Generics?

Nov 15, 2010

So I implemented my own form of Enum static classes so I can associate strings to enumeration values. One of the shared functions in each enum class, GetValue, is used to quickly look up the string value from an internal array via the offset. While all of the enum classes implement the same exact function, the data types of their parameters differ, specific to the enums in each class.

So I come to a point where I want to create a generic class that can use any of the enums by passing it as a generic type parameter. But I cannot find a way to constrain type T in such a way to be able to call each enum's GetValue function. This is where an interface would come in handy, but VB.NET forbids interfaces for shared methods.

I have a base class that I could constrain to, but the base class doesn't implement the GetValue method, and I can't define a generic version of it, because I need to rely on shared properties of each child class in order for GetValue to do its thing.[code]..

View 2 Replies

Access Shared Variables Of A Class?

Jul 23, 2009

I am making a small application in which i have added a class module and a window forms in vb.net. i want to acess the shared variables and mathods of class without making any object.

View 8 Replies

Why Doesn't XmlSerializer Work For Shared Class Variables

Dec 8, 2011

I have the following class which I want to serialize to XML:

[Code]...

View 3 Replies

OOP - Shared Methods And Base Properties?

Feb 25, 2009

If you can't use Me. in a non-instance method, how would you use properties/functions from a base class in a Shared method?

For example, ClassB inherits from ClassA
ClassB has a Shared Method DoWork();
ClassA has a ReadOnly Property SecurityKey

How do I Public Sub DoWork() Dim test as String = Me.SecurityKey End Sub

View 5 Replies

.net - Suppress A Property Or Method From A Base-class In A Derived Class?

Apr 7, 2011

Supose a base class

Public Class airplane
Private var_num_seats As Integer
Private var_num_engines As Integer

[code]....

Obviously, I don't wish that the class Glider has the method "start_engines" neither the property "num_engines". Otherwise, other child classes may have. How can I supress these property and method in child class, not just ignoring (if I can)?

View 2 Replies

Access The Base Class Inside A Derived Class?

Oct 22, 2010

How do I access the base class inside a derived class?

View 1 Replies

.net - Why Can't Call Private Shared Methods From A Public Shared Method

Aug 25, 2011

I have a class like this:

[Code]...

It works, when I make getBar methods public, but I don't want to expose these unneccessarily. Why I can't call private shared methods from a public one in the same class is over my head. I'm using .net framework 4.0 in a web application.

View 1 Replies

Create A "shared" Variable That Is Shared With All Instances Of A Class?

Jan 14, 2011

I seem to be drawing a blank. I'd like to create a "shared" variable that is shared with all instances of a class but not classes that inherit from it. For example.Class A: Shared list As New List(Of String): list.Add("A")

Class B Inherits A: list.Add("B")Class C Inherits B: list.Add("C")The end result I'd like is that any instance of A has just A in the list. Any instance of B has A and B in the list. Any instance of C has A, B, and C in the list. I can accomplish it by creating Instance variables, but I have to construct the list for each instance of a class. I'd like to construct it once for a specific point in the Hierarchy and then share it accross other instances of that class.

View 12 Replies

[02/03] Base Class Called PageBase And Then A Derived Class TestPage That Inherits From PageBase

Feb 4, 2009

I have a base class called PageBase and then a derived class TestPage that inherits from PageBase. In PageBase I have overridden the OnInit() and when it is called and I inspect the value of 'Me', it is of the type of the derived class and not the base class. My question is how does inheritance really work? For instance, when instantiating TestPage does an instance of PageBase get created too?

Here is my code;

Partial Public Class TestPage
Inherits PageBase

Public Sub New()

[code]...

View 7 Replies

VS 2008 Base/Derived Class?

Jan 17, 2010

Trying to implement some sort of commit/rollback functionality in my base objects. I have it working with some help from google. However, I have a question My Base Class has a BeginEdit as shown below -

[Code]...

Now, what I'm confused about is if I create another class, Class1, that inherits the base class. I add some properties such as Name, Age, Location, etc. to Class1.When I do Class1.BeginEdit, wouldn't "Me.memberwiseclone" make a copy of Class1, then CType try to cast it from Class1 to the BaseObject class? How does that work if Class1 has additional properties like the Name, Age..blah blah? Where do those gets stored in the Base class? I'm having a hard time wrapping my head around the concept...

View 3 Replies

Hide A Derived Method Of Base Class?

Sep 10, 2009

I would like to inherit from the Data.DataColumn in order to produce a DataTextColumn. That means that in the derived class, I dont want to see the non-applicable AutoIncrement property and the like - all I want to see are properties that apply to string types.[code]...

View 5 Replies

VS 2008 Same Interface, Base And Derived Class?

May 11, 2012

I'm struggling here.. I know I can disable the warning manually. However I'm not sure if this would be the right way to go about this.

Here's my interface..vbnet Public Interface IPopulatingClassBase Property Identity() As Int64 ReadOnly Property Dirty() As Boolean Sub Populate_Class(ByVal RecordID As Int64) Sub Save_Class() Sub Reset_Class()End Interface

[Code]...

PS In my example think of it as classes that populate with data from a database. The parent class would be an organization, and the derived class a location. Both populate and have similar functionality. The only difference is locations are an entity of an organization(the data record for a location constraints it to an organization) upon loading location data I also populate the organization class. This is a real example of what my project does.. so having said I just want to know how I can get around this warning, and if not would it have any consequences if I left it as-is.

View 6 Replies

[2008] Base Class Inherited By 2 Derived Classes

Jan 30, 2009

i've finally got round to learning about classes and inheritance, but i'm not sure how to proceed. i have a base class Employee, which is inherited by 2 derived classes. how do i use the same Employee class in both derived classes? obviously if i write a sub new for both of them + declare a new Employee class, they won't be using the same class. heres my Employee class:

[Code]....

View 7 Replies

Using Reflection To Attach / Detach Handler Of Base Event In Derived Class

Dec 13, 2009

I am just curious, if there is some way to attach handler to my derived classes base event, if I know EventInfo and I have Delegate to handler function. I have tried MyEvent.AddHandler(CType(Me, BaseClassType), MyDelegate) already, but no positive result at all. Consider being in need of attaching handler to custom event at runtime, while derived class possibly shadows this event.

View 2 Replies

Design Patterns - Inheritance - Do All Properties In The Derived Classes Have To Be Declared In The Base Class

Aug 8, 2011

Background:I have a base class and several inherited derived classes. The derived classes don't always need to have the same properties. If any properties are shared among the derived classes, those properties would live at the base class level ('Contents', for example).Similarly, GoodDocument below has 'GoodThings' but would not want/need to have 'BadThings'.I want to treat instances of both 'GoodDocument' and 'BadDocument' as type 'Document'

public mustinherit class Document
public property Contents as string
public sub new()...

[code]....

View 3 Replies

Partial Entity Class With Shared Extension Not Associated With 'other' Partial Class In Client Using RIA Services?

Apr 21, 2011

I have extended an Entity Framework 4 entity class with a calculated property in a partial class. This member is not available on the client to which the entities are exposed via WCF RIA Services.when using C# appears to be changing the extension of the partial class file from .cs to .shared.cs. I tried this with my VB.Net solution (.vb to .shared.vb) and got a long list of errors. I believe what happened is that the partial class lost its association with the entity on the client - it inherited from object rather than EntityObject.

My best guess is that this is related to the way that VB.Net handles namespaces.Each project has a 'Root Namespace' which is prepended to anything that is defined within a code file. C# has a 'Default Namespace'which is the namespace into which new types are placed by default - via a namespace statement within the file.The partial class is probably having the client namespace prepended to it which puts it into a different namespace than the entity with which it is associated on the server.Is there any means of extending an entity in such a way that those extensions are available on the client via WCF RIA Services and VB.Net?

View 1 Replies

VS 2010 : UserControl MouseEnter/Leave Events Aren't Firing - Cannot Raise Base Event From Derived Class

Feb 18, 2011

When i use my UserControl in a project my Mouse Enter & Leave events aren't firing, i assume i fix this with a raiseevents in my usercontrol. However when i try to do this it says something about "cannot raise base event from derived class".

View 7 Replies

Best Way To Initialize Shared Members In A Class

Aug 23, 2011

I was looking on the interweb to see if there were any good examples on how to initialize shared members within a class while still initializing instance variables.[code]How do I initialize both instance and shared members without re-initializing the shared members every time an object is created from a class?

View 1 Replies

C# - Reset A Static/shared Class?

May 4, 2009

I've got a shared class (static in C#) which mostly carries some settings data that any class in the application can read and sometimes write. Also there are some static properties which holds some internal states.

Now I want to revert this class to initial stage of it. With all default variables etc. Assume that the user want to reset the current state and start over without restarting the application.

In a singleton model I'd simply renew it with something like this :

Public Sub Reset()
_Instance = New MyClass()
End Sub

However this is not possible in a Shared class. Or should I switch back to Singleton?

View 3 Replies

Class Module Which Is Shared Between The 2 Projects?

Mar 29, 2010

I have no idea what is going on here but it is strange to say the least.I created a new solution in VS2008Pro under windows 7 This solution has 2 projects one for the pc and one for a CE based device.There is one class module which is shared between the 2 projects.In VS2005 under xp this same basic project worked fine but here I am seeing error messages that appear out of no where.

Example the CE portion flags 3 lines initially 1 related to a file i.o function and 2 others related to socket methods. All three of these were supported in VS2005 using framework 2.0 which is the same framework I am using here. This is just the tip of the ice berg however.If I attempt to run the code it runs fine for the pc client and of course not for the CE device. If I make any kind of change, add a line, comment a line or just add a comment I get lots more errors with odd messages that are not even valid.

In one case after I saved it jumped from 3 errors to 30, in another case to 50 and yet another to 144 errors yet the only errors that were present were the original 3 that were flagged.The ide threw errors like Try Catch must end with matching End Try.Get no longer supported ' apparently referring to the binary file get but here it is used as the get portion of the property.Get must end with matching end get.It also started complaining about functions and data types.For example saying "an is not declared" pointing to the word Boolean Or telling me my functions are not declared point to only 1/2 of the function name.

I do not see any errors in the code and it reports no errors in VS2005 under XP.As a test I tryed adding a new property to the project after it was telling me there were 144 errors. I allowed the ide to do most of the work and when I hit enter the errors went back to 3. Then I saved the project and the errors went to 105 pointing first at the new property just created.

View 5 Replies

Library Of Functions In A Shared Class?

Feb 11, 2009

I have large group of functions that I would like to store in basically a library and simply call the functions from the controls on my forms. Back in VB 6 I would have done this with a module, but now I have been told that a Public Class is the correct way in .NET. How should I go about doing this?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved