Private Or Protected Set For A MustOverride Property?

Jul 24, 2010

I'd like to have a Private or Protected "Setter" for a property that also happens to be an abstract (MustOverride). I'm porting some code from C# to VB and in C# this is pretty straight forward. In VB not so much (for me anyway).

Some code...

In C#...
public abstract class BaseClassWithAnAbstractProperty
{
public abstract int AnAbstractIntegerProperty { get; protected set; }
}

[Code]....

The issue seems to be the inability to flesh-out the Get/Set specifics in the declaration.

View 2 Replies


ADVERTISEMENT

Reflection - Find From A Property Info Object If That Property Has A Non Public (Private / Protected) Setter?

Aug 27, 2009

I searched on the forum / Internet for the solution how a PropetryInfo object (of a Public property) can reveal if it has a Private Protected Setter ... it was all in vain .... all help I found was about how to "Set" value of a public property having a Private Setter.I would like to know if I have a PropertyInfo object of a public property, how would I know if its Setter is Non Public?

I tried, in a exception handling block, where I did a GetValue of the PropertyInfo object and then called SetValue by setting the same value back... but to my surprise it worked well and didn error out.

[Code]...

View 1 Replies

CodeDOM, VBCodeProvider And MustOverride Property?

May 27, 2007

I'm having trouble with CodeDOM and the VBCodeProvider.I want to generate an abstract class with a MustOverride ReadOnly Property.

View 3 Replies

Error : Protected ReadOnly Property InnerChannel As TChannel' Is Not Accessible In This Context Because It Is 'Protected'

Apr 12, 2010

I am having a Friend Class InterceptingChannelBase class.It has a property as below:

Protected ReadOnly Property InnerChannel() As TChannel
Get
Return Me.innerChannelT

[code]....

This class is being inherited by (Friend Class InterceptingInputChannel) class which in turn contains another (Private Class TryReceiveAsyncResult) class.The property above is being used in this private class as below:

Public Sub New(ByVal channel As InterceptingInputChannel(Of TInputChannel), ByVal timeout As TimeSpan, ByVal callback As AsyncCallback, ByVal state As Object)
MyBase.New(channel, callback, state)

[code]....

I am getting the error on the above underlined statement saying that Protected Readonly Property InnerChannel is not accessible in this context because it is declared asa Protected.As far as i think,if i declare a property in class as 'Protected' then if this class is inherited by 'another' class then i can use this property and it should not throw an error.

View 3 Replies

Private Vs Protected - Button Click Event Is Created In ASP.NET ?

Feb 22, 2012

In ASP.NET using VB.NET, you can define the wired up button click event (to an ASP.NET server control) in 2 different ways (for the purpose of this conversation - manually wiring up via button property not in question here):

Double click on the button in the designer which produces an event in the code behind with a Protected method.In the code behind, select the button from the list of controls, and then select it's 'Click' event. This produces a Private method.I understand the difference between Private and Protected; why based on how the wired up event is autocreated it generates a different Access Level on the method?

View 1 Replies

What Use Cases Exist For Non-static Private Or Protected Events

Sep 25, 2009

What purpose do protected or private (non-static) events in .NET really serve?It seems like any private or protected event is more easily handled via a virtual method. I can (somewhat) see the need for this in static events, but not for normal events. Have you had a use case before that clearly demonstrates a need or advantage for a non-static protected or private event?

View 5 Replies

C# - Invoking Private / Protected Methods Via Reflection From The Same Object Instance (or Base)

Jan 5, 2012

Is it possible to call a protected method via reflection. I am using this:

Me.GetType.InvokeMember(Stages(CurrentStage),
Reflection.BindingFlags.InvokeMethod,
Nothing,
Me,
Nothing)

Which always calls a method with no params or return. The idea is that the user of my object (transactional processing of business logic) inherits the base class adds in a load of private methods to fire. They then add these method names to a list in the order they would like them fired and the code above will take care of firing them.

It works fine with public methods but not with private or protected methods in the same class (Protected because I have some 'standard' pre built methods to add to the base class). Realistically I could make the methods public and be done with it but my inner nerd wont allow me to do so...

I am assuming this is a security feature. Is there a way to get around this or does anyone have any suggestions on how to proceed but keep my tasty, tasty visibility modifiers in tact?

(NOTE: ITS IN VB.NET but a C# Answer is fine if that is what you are comfortable with).

View 3 Replies

VS 2008 - Difference Between Public, Private, Protected When Declaring Functions And Subs?

Jul 19, 2009

i have have a few questions about the syntax of the lan.:

1) What is the 'Get' statement and when do you use it?

2) Whats the difference between public, private, protected etc... when declaring functions and subs.

3) When would you use the overrides property?

View 4 Replies

C# - ReadOnly Property Or Property With Private Set Should Use?

Jan 26, 2012

I Like .NET automatic properties, in C# it so easy to declare readonly property by declaring its set section as private like this:

public String Name{ get; private set; }

But when I tried that in VB.NET I was shocked that it is not supported as mentioned here and I have to write it as follows:

Private _Name as String
Public ReadOnly Property Name as String
Get

[Code].....

What the difference between these declarations in VB.NET, which one is preferred and Why?

Which one will affect compile time, runtime or performance at all?

View 3 Replies

C# - Protected Set For A Property Defined In An Interface

Mar 2, 2010

We have an interface, which can be grossly simplified as:

[Code]...

View 3 Replies

MVC - Virtual Property To Be Set Private For IDs

Jan 28, 2010

I am trying to use fluent nhibernate in a MVC project. It seems the entities should have properties that are virtual and the set should be private for IDs. I use vb language. So tried using overrideable. It gives an error...

Public Overridable Property DesignId() As Integer
Get
End Get
Private Set(ByVal value As Integer)
End Set
End Property

It says property cannot be overrideable because it has a private accessor.

View 3 Replies

Have The Get Part Of A Property Available As Public But Keep The Set As Private?

Sep 22, 2009

is there a way to have the Get part of a property available as public, but keep the set as private?Otherwise I am thinking I need two properties or a property and a method, just figured this would be cleaner.

View 3 Replies

Make A Property Public Get But Private Set?

Apr 25, 2009

I just stumbled over this in some C# code...:public Foo Foo { get; private set; }

View 2 Replies

Private Property Visible When It Shouldn't Be?

Jan 3, 2010

I'm using VS2008 and have created a dll with the following

Public Class Test
Private privatesampleProperty As String
Public Property SampleProperty() As String
Get

[code]....

From what I can see this should not be visible outside the class...

View 1 Replies

Properties - .net Property Get And Set Values Without Private Variables?

May 4, 2012

I am programmer from some time only, I have certain doubts in fundamentals, could you please clarify on the following:Case 1:

[Code]...

Does case 1 and case 2 yield same result, I mean is a private value necessarily in there?, can we use property itself to use its own value in its Set and get statements?

View 2 Replies

Property ReadWrite In Private And ReadOnly In Public?

Feb 23, 2009

Can i have a property that is Readonly for Public but can Read/Write in Private?

View 4 Replies

C# - Using The Value From The Private Variable Or From The Actual Property In Class Functions?

Dec 30, 2009

When referencing class properties from a function within the class do you use the value from the actual property or the private variable value?

public class
private m_Foo as double
public property Foo() as double

[Code].....

View 7 Replies

Advantages Of Property Keyword Over Using A Private Field With Getters And Setters?

May 21, 2011

In VB.NET, what are the advantages of using the Property keyword rather than:[code]Coming from Java I tend to use this style rather than Property...End Property - is there any reason not to?

View 4 Replies

Asp.net - Benifit/Advantage Of C# Property Properties - Private Access Modifiers For Setters?

Jan 25, 2012

Below is the class with a property.

public class abc
{
public int MyProperty { get; private set; }
}

What's the benefit of typing private access modifier in setter ?

View 5 Replies

How To Do MustOverride Sub New

Nov 18, 2011

Is it possible to force the inherited classes to implement a set of New() constructors? I tried with this, but it doesn't work:
MustOverride Sub New()
MustOverride Sub New(Arg1 as Integer)
MustOverride Sub New(Arg1 as String)

View 7 Replies

Can't Make Difference Between Public Class And Private Class And Friend And Protected Friend Class

May 15, 2009

I can't make difference between public class and private class and friend and protected friend class.

View 1 Replies

Protected Error In Compile Time, When No Protected Class Is Used?

Nov 10, 2011

Dim box As MultiTextBox = New MultiTextBox

Dim i As Integer
for i = 1 to 3 Step 1
lengthWidthHeight = MultiTextBox.GetItemValues()
Next i

This excerpt of code is using the NXOpen API. In the NXOpen API, the MultiTextBox class is public. However, when I compile the code I get the message:

'NXOpen.UIStyler.MultiTextBox.Protected Sub New(ptr As System.IntPtr)' is not accessible >in this context because it is 'Protected'

My question is, how am I getting an error about protected scope? Could it also be that the API documentation is incorrect?

View 2 Replies

Error 58'Protected ReadOnly Property Profile() As System.Web.Profile.DefaultProfile' Has Multiple Definitions

Jul 22, 2009

when building my application I am getting some temporary files shown in Solution Explorer under Miscellaneous Files lie App_Web_YDKG.VB with following code block in that generating error

Protected ReadOnly Property Profile() As System.Web.Profile.DefaultProfile
Get
Return CType(Me.Context.Profile,System.Web.Profile.DefaultProfile)
End Get
End Property

Error : Error 58'Protected ReadOnly Property Profile() As System.Web.Profile.DefaultProfile' has multiple definitions with identical signatures.C:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Filesinfinityvb2ae71c27d560144bApp_Web_pwduczex.38.vb456

View 3 Replies

Access A "private Virtual" Property Starting With Underscore Through Reflection?

Apr 10, 2011

I was trying to access the following property using Reflection because I don't have the original source code (suppose this was decompiled through Reflector). It seems that something is special about it being "private virtual" or maybe because it has "_" in the beginning of the property. I can access all the other private properties no problem except this one. Just can't figure out what I am doing wrong:

private virtual String _MyProperty
{
get

[code]......

View 5 Replies

C# - Access A "private Virtual" Property Starting With Underscore Through Reflection?

Jul 15, 2011

I was trying to access the following property using Reflection because I don't have the original source code (suppose this was decompiled through Reflector). It seems that something is special about it being "private virtual" or maybe because it has "_" in the beginning of the property. I can access all the other private properties no problem except this one.

private virtual String _MyProperty
{
get
{

[code]....

View 2 Replies

VS 2008 Sharing Variables - Private Sub Could Use The Variable Created On Private Sub

Jul 23, 2010

if for example i have two private sub I declared a local variable on private sub a... is there a way that private sub b could use the variable created on private sub a? Im asking because im in a problem in my app were using global variable is not an option to make the long story short

View 5 Replies

What’s The Difference Between Private Sub And Private Function

Dec 14, 2011

I am completely lost on procedures. Whats the difference bewteen Private sub and private function?

View 1 Replies

Inheritance - Specify A Return Type Of "Derivative(of T)" For A MustOverride Sub In .NET?

Apr 22, 2010

VB.NET 2008 .NET 3.5 I have two base classes that are MustInherit (partial). Let's call one class OrderBase and the other OrderItemBase. specific type of order and order item would inherit from these classes. Let's call these WebOrder (inherits from OrderBase) and WebOrderItem (inherits from OrderItemBase).

Now, in the grand scheme of things WebOrder is a composite class containing a WebOrderItem, like so:

[Code]...

View 1 Replies

.net - 'Property' Cannot Implement 'Property' Because There Is No Matching Property On Interface 'IName'?

Dec 9, 2011

I'm having some very weird issues with interfaces right now.

I have a very simple setup. In one of my class, I have a Property implementing a Property from an Interface.

In my class it's like:

Private _oForm As IForm
Public Property Form As IForm Implements IContainer.Form
Set(value As IForm)

[Code]...

I have like dozens of interfaces like this working throughout my project and I can't believe this simple one can't work!

View 1 Replies

Calling Private Subs In Another Private Subs?

Jun 15, 2009

I'm trying to call a private sub in another private sub. For example ;

[Code]....

View 13 Replies







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