|
|
Diana Fernandez wrote: Is it possible to prevent accessing a method in derived class?
Yes. Go with Private Access Modifier.
Regards,
Satips.
|
|
|
|
|
Consider the scenario given below
public class Base
{
protected string _name = null;
public void SetName(string Name)
{
_name = Name;
}
}
public class Derived : Base
{
public void SetName(string Name, bool Condition)
{
if (Condition)
_name = Name + "true";
else
_name = Name + "false";
}
}
How is it possible to prevent accessing the Base class method on the object of derived class? Because base class implementation should not be used on the object of derived class.
|
|
|
|
|
Hello,
in this case you should declare it as virtual und override method.
public class Base
{
protected string _name = null;
protected virtual void SetName(string Name)
{
_name = Name;
}
}
public class Derived : Base
{
protected override void SetName(string Name, bool Condition)
{
if (Condition)
_name = Name + "true";
else
_name = Name + "false";
}
}
All the best
Martin
|
|
|
|
|
That will not compile, the method signatures differ.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Uuupss,
Haven't seen that.
than the 'new' would be best todo I think.
public new void SetName(string Name, bool Condition)
{
if (Condition)
_name = Name + "true";
else
_name = Name + "false";
}
}
All the best,
Martin
|
|
|
|
|
Diana Fernandez wrote: Because base class implementation should not be used on the object of derived class.
It's a feature of OO ( and the whole point of inheritance ) that derived classes DO inherit the base methods. The best you could do is make SetName virtual on the base class, and override it on the derived, so it calls the new method with a default condition, or have it throw an error.
public override SetName(string Name)
{
SetName(name, true);
}
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Or use aggregation instead of inheritance - maybe in combination with an interface.
-^-^-^-^-^-
no risk no funk
|
|
|
|
|
Hi All,
The requirement is to create factory class that implements a set of cross-cutting aspect classes and provides configuration to create user defined implementations for them at runtime. The user defined assemblies implement the Command pattern, and are invoked in the order they are configured. This requires using Enterprise library for handling configuration data in an external configuration file.
The factory is a singleton class. It references each aspect by an interface. The factory also defines wrapper class to invoke aspect method calls, and load the assemblies on demand.
Please Provide the necessary code and material.
Thanks,
Ramesh Bhojan
|
|
|
|
|
rameshbhojan wrote: Please Provide the necessary code and material.
OK, this is what's called homework. Your teacher is allowed to say this to you, but when you ask people you don't know, to do your homework for you, it's not really the right approach to take.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Don't Cross Post.
Regards,
Satips.
|
|
|
|
|
Hi friends!!.can you help me work with timer control in the web form......
Hi,Im Razana
|
|
|
|
|
You can't, because the timer runs on the server, and your page runs on the client. You can write a timer in javascript, which will execute on the client.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
As CG said timer runs on the server side and the control pages runs on the Client side so please try to implement the Javascript, which will execute on the client.
Here is the Code for the Timer control using Javascript.
Regards,
Satips.
|
|
|
|
|
Thank You Graus and Satips...
Hi,Im Razana
|
|
|
|
|
Glad to Help always.
Regards,
Satips.
|
|
|
|
|
could you tell what do you want to do ??
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
I have made one User Control which exposes some properties. All these properties are browseable. Hence, when I put my user control on any form and selected the user control, I am able to see the custom properties in property pan at design time.
At design time, I want the button to be displayed against the property item for setting its value. So when user wants to modify the value of this property, user will click the button available. Clicking of button will open up custom form which assist user in configuring the property value.
In framework 2.0, there is control named Masked Text box. This control has got Mask property. I want something similar to this Mask property configuration.
Pls Help.
|
|
|
|
|
First time I didn't get any help from this board but ultimately I got the solution. Type 'IWindowsFormsEditorService' in MSDN for more detail on solution
|
|
|
|
|
hi i refered to an website this[^]
exactly and create an console application however the program only pop up an console and when i try to key in something in it. an run time error occur : Index was outside the bounds of the array.
could some one please aid me in this..
how come its not working??
|
|
|
|
|
|
hey,
I want to use MouseWheel for my drawing application...Idea is to expand and contract a circle depending upon the direction of wheel motion...which function/property to use..?
thanks
|
|
|
|
|
It will take more than a function or property to do that. You can use Mouse Move for sure but will have to add drawing and all those things. Try to do a research on System.Drawing.
|
|
|
|
|
Hi,
there are at least two approaches to do such things.
1.
Every shape (line, rectangle, circle, ...) could be a (user-defined) Control;
in that case you create and select a shape, then it gets its events fired
such as MouseWheel.
2.
In a lightweight approach (which I prefer) only one Control is involved (say a Panel)
on which you create your drawing. Now it is the Panel itself that gets the events,
such as MouseWheel.
In both cases, the MouseEventArgs.Delta property will tell you how much the wheel
has moved (and the sign of that will tell the direction). You should follow UI design rules
as explained in MSDN, concerning SystemInformation.MouseWheelScrollLines
|
|
|
|
|
hi i am currently trying to make an console application with c# which telnet and use the command line : "show cdp neighbour" is that possible? if it is pleaswe show me the way please i feel its a veri useful skill
|
|
|
|