|
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?
|
|
|
|
|
|
I posted a couple of messages on this topic last month. I got a lot of great help and suggestions, but after taking the time to implement all of them I'm still not able to connect to my database over the network.
Using the CodeProject tutorial: "Hands on how to configure the Microsoft MSDE" I just did a fresh install of MSDE 2000 enabling networking and using windows authentication. The instance is DomBenBSA running on computer DB-NGIVENS. I accidentally killed my testing database, but I recreated it and attached it to the server: it's BenefitSelectDB.
So now I have the server running and I go to my laptop. I'm logged onto the domain (DB) with my standard login (NGIVENS). I'm using RapTier to try and connect to the database (it's just faster than running test C# connection strings).
I can detect the server (DB-NGIVENS) - which is more than I could do before - but when I try to get to the database I get this error (when i'm using Windows Auth):
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
Here's the interesting thing. I go back over to the host machine where I have the server installed and check out my list of users. I don't see myself anywhere. So I add the user 'DB-NGIVENS'. When I try that, I get this error:
Msg 15063, level 16, State 1, Server DB-NGIVENS\DOMBENBSA, Procedure sp_grantdbaccess, Line 116
The login already has an account under a different user name.
So now I'm confused. If the login already has an account under a different name - how can I logon from another computer where I'm logged in as myself?
Any help would be SO appreciated.
(By the way, here are the users that I do find:
db_accessadmin
db_backupoperator
db_datareader
db_datawriter
db_ddladmin
db_denydatareader
db_denydatawrier
db_owner
db_sercurityadmin
dbo
guest
public)
The ends can never justify the means. It is the means that determine the ends.
|
|
|
|
|
I am looking for a way to autoselect ListView Items on Key Press event based on the sorted column.
The behaviour should be similar to Windows explorer.
If one types the keys very fast the keys should be buffered and the buffer string should be compared with the sorted column. If the speed is slow, the buffer is cleared.
Can somebody guide me to some article on this? I tried to google but to no avail.
I know this is available on of-the-shelf ListView. But this works only for the first column.
I need this on the sorted column.
|
|
|
|