|
What is homework ?
What is google ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Virtual methods are those methods which you want to call using base class object with derived class reference.
namespace SomeCorpProject
{
public class BaseBusinessObject
{
public BaseBusinessObject()
{
}
public virtual void VirtualMethod()
{
Console.WriteLine("Virtual method");
}
public override string ToString()
{
return "BaseBusinessObject";
}
}
}
namespace SomeCorpProject
{
public class Capacitor : BaseBusinessObject
{
public Capacitor()
{
}
public static void StaticMethod()
{
Console.WriteLine("I am static, no need to create object of class.");
}
public override void VirtualMethod()
{
Console.WriteLine("In derived virtual method");
base.VirtualMethod();
}
public override string ToString()
{
return "Capacitor";
}
}
}
namespace SomeCorpProject
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
BaseBusinessObject bizObj = new Capacitor();
bizObj.VirtualMethod();
Capacitor.StaticMethod();
System.Console.WriteLine(bizObj.ToString());
}
}
}
The above code will explain most of the concepts. Static methods are those methods for which object of the class need not to be created. They share the common info across all class objects. They are loaded in the memory before class gets loaded. Dynamic methods? I do not have idea. But I think they might be instance methods. i.e. you should create an object of the class to call these methods.
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
jdkulkarni wrote: Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
Wow - is that worth something in parts of the world ?
I wouldn't have given the answer, because all you're doing is teaching this person to not do their own homework. I hope he ends up working in the cubicle next to you and not near me.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
As far as hand feeding, I couldn't agree more. Unfortunately, I think I do sit next to him
|
|
|
|
|
Just adding a little, virtual methods can be overwritten in a derived class (by using overwrite keyword) but is not mandatory. Also you can have a method with the same name as the one in a parent class and hide it with a technique called shadowing (by using new keyword).
modified 17-Jul-19 21:02pm.
|
|
|
|
|
Have you heard of MSDN ??
Regards,
Bhupi Bhai.
|
|
|
|
|
In my current project I want to replace a library I'm using by an other one I will write my self.
1st I want to write a skeletton library which feature all type/method I'm using (with no real code inside).
For that I would like to go through my project, track every library object I'm using and all the method I'm calling and create a mock-up library where I would define all the types and and methods I'm using from the 3rd party lib.
The thing is I would like to do it automatically through someting like reflection.
Is there a way I could do that simply? Any tips or links?
Here is an example, current code below
class MyProject
{
void AMethod(ALibObject1 obj)
{
obj.Method1();
ALibObject2 o2 = obj.Method2();
o2.Method3(new LibObject3());
}
}
I want to go through the code (or probably compiled assembly) above (automatically), by using reflection on the assembly (or something similar) and produce:
public class ALibObject1
{
public void Method1() {}
ALibObject2 Method2() { return null; }
}
public class ALibObject2
{
public void Method3(LibObject3 obj) {}
}
public class LibObject3
{
}
Any tip on how to do that simply in an automated way?
|
|
|
|
|
|
|
Hi,
After I copy and paste some excel cells into a richTextBox in window form, how can I edit the excel data in the richTextControl, so that it can reflect the changes back in the excel source ?
Thanks
|
|
|
|
|
Hi!
If you simply paste Excel cells into a RTB, they're pasted as a RTF table without any information that the cells have been put into the clipboard from a certain Excel sheet. So there is no way back.
You're out of luck here, sorry.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi,
I need to import data in an XML file onto an Excel sheet using C#. How can I do this?
I tried using XMLIMPORT method, but its for MS Excel Professional Edition only and I am working with MS standard edition.
Rgds,
UH
|
|
|
|
|
I have an array of letters which’s makes a word and I was wondering how I could compare a user’s input letter against the letters in the array so when running it would display something like this
Example
** Word to be guessed in array – train **
User inputs letter a
Displays _ _ a_ _
User inputs letter n
Displays _ _ a _ n
User inputs letter t
Displays t _ a _ n
And so on until the word is complete.
If some1 could provide an example I could follow id be most grateful as I purchased a book a few days ago on c# programming and this is one of the tasks it doesn’t really give much info on how to do it. i know it uses a loop to move along and check each character but im not sure on this.
thanks
|
|
|
|
|
sound like hangman
Programmer: A biological machine designed to convert caffeine into code. * Developer: A person who develops working systems by writing and using software.
[ ^]
|
|
|
|
|
in a way yes, i guess it is the same principle, but i dont need to draw anything i think that is later on in the book, i have just been given a word in a string that i need to get the user to figure out, but its not very clear
|
|
|
|
|
neptune2k wrote: I purchased a book a few days ago on c# programming
It is a common misconception that learning to program is "equal" to learning a programming language. Evidence of it abounds here in these forums. Anyway, you need a book on Programming Logic and Design[^].
led mike
|
|
|
|
|
I've enabled drag/drop on several ListBoxes via the MouseMove event. When I call MyListBox.DoDragDrop(...) from the event however the SelectedIndexChanged event doesn't always fire, and the various ListBox.SelectedFoo properties do not update. I can get the selected items for the drag/drop action by calling the GetSelected method for every item in the listbox, but having to do so is an ugly hack.
More seriously, I can't safely manually call the method I have attached to the SelectedIndexChanged because if the event has never fired normally, trying to access the SelectedIndex property returns an IndexOutOfRangeException. If I comment out the call to DoDragDrop, this problem never occurs so I know somehow it's responsible for what's going on.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
I've partially kludged around this by setting SelectedIndex at the same time as I'm using the GetSelected Method to check which items are selected to generate my drag/drop event.
This appears to fix the problem about 99% of the time. Occasionally however, while doing a series of very frantic clicks on the list I manage to get two items shown as selected in the UI even though clicking on one should automatically clear the selection on the prior item. When this happens, I'm still having my SelectedIndexChanged event fire with the SelectedIndex property filled iwth an indexOutOfRangeException. When looking at the returns from GetSelected in the debugger, only one of the two items that appear selected in the UI are returning true.
The listbox is using the multiExtended selection mode, so it shouldn't be possible to select multiple items with hte mouse at all.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Hi All,
I have a c# form for the user to fill in the registration info. However, the user will get Syntax error (missing operator) in query expression when he fill in the form with "'s" or "<%" or "<#". I am using Regex.Replace(textbox.Text, "'", ""); but I need to save the "'s" in DB. I would like to know if there any solution for this issue? Thanks in advance.
TMA
|
|
|
|
|
TMATMATMA wrote: I have a c# form for the user to fill in the registration info. However, the user will get Syntax error (missing operator) in query expression when he fill in the form with
This is because the values are being "injected" into the SQL Command. A very bad practice that leads to innumerable security failures for your database.
Read this article[^] it will tell you exactly why you are getting the problems you are getting and exactly how to fix it.
|
|
|
|
|
hi folks
how do i set the margin and paper to landscape in the code window with reportviewer
let say am using c#
|
|
|
|
|
There is a very good site @ report viewer. http://www.gotreportviewer.com[^] Hopefully this will help.
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
Since I am new to database, I want to know how to approch that.
Assume that I have a table, I call it table A with the follwoing fields
A | B | C | D
==================================
Now, table A will take value from the fields like
[A1], [B1], [C1], D[1] etc.
Given that for each value added to field A, I want to create another table. For instance, for the above example, I will have a table A1 with fields like
A11 | A12 | A13
===============
The same for A2 etc.
The way to look at it, for each value added to field A of the original table, I want to have another table. I want to know if this is the best way to do it. I couldn't find any other way.
|
|
|
|
|
If the relation is 1 to n then it is ok
Each item of table B would have an index refering to Table A item.
But if it is an n to n relation, then you should have your two tables (A & B) and then a Table C with A & B indexes.
Hope it helps.
|
|
|
|