|
|
I'm trying to get my head around objects and am asking for thoughts on this
idea.
If for example I were to implement a Person Object, there may be differnt
Person objects representing people of different cultures.
All Person objects have similar characteristics, ie Height, Weight, Age ect
but I imagine that there could be a method ie SayHello which Person objects
of different cultures would implement differently.
Now what i'm trying to figure out is whether the Person Class should be
abstract to cope with different cultures or whether I should create an
interface or both.
Thoughts and comments appreciated.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
LearnVisualStudio.Net
|
|
|
|
|
Although you could implement it with interfaces, a simple virtual method for SayHello, or other methods, would be simplier.
|
|
|
|
|
Hello
I don't think there are any requirements for using interface in your case.
You can create your base Person class, with a virtual SayHello method. You can provide it with default realization (may the person can greet you on some kind of default language of human being saying "Mmmm" or with some other action). Then, any other class, which will inherit your base class, can override the method. Or you can make the method abstract to make it obligate to provide realization of the method.
With best regards,
Andrew
|
|
|
|
|
Why make the SayHello method virtual? Could you noy just Override the method in the derrived class?
I understand that making it abstract forces the derrived class to implement the method in its own way but again, could this not also be achieved by Overriding the inherited method?
Is there a benefit or forefeit to either approach?
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
LearnVisualStudio.Net
|
|
|
|
|
You can only override a virtual method. That is the reason for making it virtual.
---
b { font-weight: normal; }
|
|
|
|
|
I agree with Andrew, I think that would be the best way to solve this requirement. You can override the method of sayhello of base class and implement it in the child class
Regards,
Jaiprakash M Bankolli
|
|
|
|
|
the rule of thumb is:
class inheritence is used as "is a" ... "an american IS A person"
while interfaces are more used in a context of "can perform something"
"money is cloneable" (where you might have ICloneable)
//Roger
|
|
|
|
|
Hi. I'm writing console application and I want to use MessageBox in it. I'm addins System.Windows.Forms namespace but i cant use MessageBox in my program. When I try directly call members of System.Windows.Forms there are only three 'WebBrowserPermision*' and nothing else.
Can anyone tell my why and how I use MessageBox in console app?
thx.
|
|
|
|
|
Can anyone tell my why
Why? That's a good question. A console app is not a Windows App and can't be forced to be one. You could create a Windows app that has a hidden window and create a cmd prompt to run your console app. But why go to the trouble, do you really need to have a console app?
|
|
|
|
|
If you really need it, add a reference to System.Windows.Forms, then you can use the reference to do a MessageBox call. But I question why you would need to do this; a console application shouldn't be using UI components for several reasons.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
I want to use a MessageBox in separate class to report exceptions like "file not found" but I test this class in console application.
I started learing C# today, so its hard for me to understand what should I do without example.
Reference? Uhm... in C++ I only had to add #include <windows.h>
|
|
|
|
|
Are you using Visual Studio? If so, right-click on your "References" folder in the Visual Studio Solution Explorer, and click "Add Reference". Find the System.Windows.Forms.dll and add a reference to that. Now you can use anything in the System.Windows.Forms namespace.
The reason .NET is broken up among several dll files is that loading a single large dll is too costly, and most developers wouldn't use even a quarter of the functionity available in the big dll. So Microsoft split up the framework into chunks: System.dll, System.Xml.dll, System.Windows.Forms.dll, etc. If you need functionality from those, you add a reference to that dll.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
Thx a lot, that's exactly what I needed
Strange that it wasnt mentioned in any book/tutorial I read.
|
|
|
|
|
.NET includes a way to encrypt something with RSA private key
and decrypt with RSA public key?
or do I have to use an external component
anyone has references or code snippets?
thanks in advance
|
|
|
|
|
|
Well I did checked MSDN, but since I have never used this namespace I have the doubt, the RSA implementation in .NET asks the public key to encrypt and private to decrypt but I need the opposite
the private key to encrypt and the public one to decrypt, is this possible?
-- modified at 16:06 Tuesday 20th September, 2005
|
|
|
|
|
RSA keys are 'symetric' (not the best choice of words but I can't think of anything better to use). You can pass the public key to the private parameter and vice versa, and it will work. This's the principle difference between encrypting and signing a document (the other being that signing only runs a hash through the RSA algorithm).
|
|
|
|
|
Hi all,
I had found the way to change parameter field of crystal report in .NET in this page http://msdn.microsoft.com/library/default.asp?url=/library/en-us/crystlmn/html/crtskparameterfieldsruntimecustomization.asp
Problem is i can not method ParameterFieldName() for variable parameterfield
I any one help i would be obliged
Following code is from the link sited above
ParameterFields paramFields = new ParameterFields ();
ParameterField paramField1 = new ParameterField ();
ParameterField paramField2 = new ParameterField ();
ParameterDiscreteValue discreteTulane = new ParameterDiscreteValue ();
ParameterDiscreteValue discreteDenlane = new ParameterDiscreteValue ();
discreteTulane.Value = this.tulane;
paramField1.set_ParameterFieldName("ntulane");
paramField1.set_CurrentValues(discreteTulane);
paramFields.Add(paramField1);
discreteDenlane.Value = this.denlane;
paramField2.set_ParameterFieldName("ndenlane");
paramField2.set_CurrentValues(discreteDenlane);
paramFields.Add(paramField2);
this.crystalReportViewer.ParameterFieldInfo = paramFields;
Thanks alot for support!
Naveed Kamboh
|
|
|
|
|
OK, I'm trying to reinstall MSDE 2000. Used control panel->add/remove programs to get rid of the last one.
But no matter what isntance name I use in the setup ini file (or command line) I get the error "The specified instance name is invalid."
Any ideas?
The ends can never justify the means. It is the means that determine the ends.
|
|
|
|
|
Hi everyone…
I am using .Net Remoting (C#). I need to use a WebClient do get an image from a URL. I need to constantly retrieve the image, therefore I have the code in an infinite loop (within a thread). The thread sleeps for ½ a second.
The code runs fine if I run it without using Remoting, however when I use Remoting the program uses up all the memory on the server!
I have stripped the code of all complications. Basically all the thread does it:
System.Net.WebClient webClient = new System.Net.WebClient();
webClient.DownloadData(URL);
And then it sleeps. But as I say, this uses up all the memory resources?
I then moved the code into a console application that does the webClient.DownloadData(URL) call, then it calls a method on the remote object to pass it the data. But I ended up with the same problem, all the memory got used up?
Please try using the web client, within a continuous thread, and within Remoting.
As soon as I mix Remoting and the WebClient, the memory gets used up. The page file usage sky rockets!
Am I missing some obvious flaw with trying to use Remoting and a WebClient together?
Can anyone offer me some advice????
|
|
|
|
|
Hy,
short and barely: How to read my own EMailAddress from Outlook.
I'm lose hope.
Thanks
|
|
|
|
|
How do I use ASP.Net with C# to create a counter for a website?
jeff19
|
|
|
|
|
|
I would like to make the whole application in C# and reserve some place in main form for animation, which I would like to perform using OpenGL in C++. Is it possible? If yes, how?
|
|
|
|