|
Now i have two things in my mind. One is common and quite easy way to inherit class in normal way. Classical inheritance.
Eg:
<br />
using System;<br />
<br />
namespace ConsoleApplication6<br />
{<br />
class BaseCls<br />
{<br />
public BaseCls()<br />
{<br />
}<br />
public void Display()<br />
{<br />
Console.WriteLine("I am from base");<br />
}<br />
}<br />
class FirstDerivedCls:BaseCls<br />
{<br />
<br />
public BaseCls Bs;<br />
public FirstDerivedCls()<br />
{<br />
Bs = new BaseCls(); <br />
}<br />
public new void Display()<br />
{<br />
Console.WriteLine("I am from derived");<br />
<br />
}<br />
}<br />
class SecondDerivedCls:FirstDerivedCls<br />
{<br />
static void Main()<br />
{<br />
BaseCls B=new FirstDerivedCls();<br />
FirstDerivedCls F=new FirstDerivedCls();<br />
B.Display();<br />
F.Display();<br />
F.Bs.Display();<br />
}<br />
<br />
}<br />
<br />
}
Another idea is Ad-hoc or containment form of Inheritance. I already post few answers for containment or ad-hoc inheritance. I would like past the answer once again here.
<br />
using System;<br />
<br />
namespace Containment_and_Nested_Class<br />
{<br />
public class Radio<br />
{<br />
public Radio()<br />
{}<br />
public void TurnOn(bool on)<br />
{<br />
if(on)<br />
Console.WriteLine("Jamming.....ON");<br />
else<br />
Console.WriteLine("Quit Time.....");<br />
}<br />
}<br />
public class Car<br />
{<br />
private Radio theMusic;<br />
private int CurSpeed,MaxSpeed;<br />
private string PetName;<br />
bool dead;<br />
public Car()<br />
{<br />
dead=false;<br />
MaxSpeed=100;<br />
theMusic=new Radio();<br />
}<br />
public void CrankTunes(bool state)<br />
{<br />
theMusic.TurnOn(state);<br />
<br />
}<br />
public Car(string name,int max,int cur)<br />
{<br />
PetName=name;<br />
MaxSpeed=max;<br />
CurSpeed=cur;<br />
dead=false;<br />
theMusic=new Radio();<br />
}<br />
public void SpeedUp(int delta)<br />
{<br />
if(dead)<br />
Console.WriteLine(PetName+"is out of Speed");<br />
else<br />
{<br />
CurSpeed+=delta;<br />
if(CurSpeed>=MaxSpeed)<br />
{<br />
Console.WriteLine(PetName+"has over heated");<br />
dead=true;<br />
}<br />
else<br />
Console.WriteLine("\t Current Speed="+CurSpeed);<br />
}<br />
}<br />
<br />
<br />
}<br />
public class MAINCLASS<br />
{<br />
static void Main()<br />
{<br />
Car one=new Car();<br />
one.CrankTunes(true);<br />
for(int i=0;i<10;i++)<br />
one.SpeedUp(20);<br />
one.CrankTunes(false);<br />
}<br />
}<br />
}
Sreejith Nair
[ My Articles ]
|
|
|
|
|
I've understood what you mean! It's a big problem!
Thank you for your information!
Bye!
"Catalonia is not Spain"
|
|
|
|
|
Hi
I developed a interface in C#,When I compile the Code it is generating .DLL output.
Now I wand the output as .EXE, Can any one explain how to do ths.
Is it required any code changes?
Thanks in Advance
krishna
|
|
|
|
|
Do you use Visual Studio? If yes, you can change the output file type in the project properties (Project => Properties => General).
skrishnasarma wrote:
Is it required any code changes?
A .EXE must have one entry point, that means the project needs at least one class with a "Main()" method.
_________________________________
nur Idioten brauchen einen Führer
|
|
|
|
|
In addition to what Corinna said: The main() method must have the [STAThread] attribute.
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
jan larsen wrote:
The main() method must have the [STAThread] attribute.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Oops, seems like I'm a bit too used to VS.NET.
For some reason VS.NET insists on putting that attribute on the main() method when auto generating a main class....
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
Is there any API to judge if card be inserted into the socket of a cardreader?
|
|
|
|
|
Winodws doesn't have anything like this. You would need to consult with the Software Development Kit documentation for the device your working with, IF one exists.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi all,
I want to add menu items when the user clicks the icon at the task bar at the bottom of the pocket pc. But I can't find code on it. The only code I found is that it can only launch a form when the user click the icon at the task bar, but not launch a item menu just over the task icon.
So are there any reference for it ?
Thanks
|
|
|
|
|
Since your question is platform specific and has nothing to do with C# at all, you might want to ask this in the Embedded/Mobile Forum[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
how can i merge dll's into one dll?
|
|
|
|
|
You want to merge two or more unmanaged .dlls or managed ?
Sreejith Nair
[ My Articles ]
|
|
|
|
|
i want to merge managed dlls...
|
|
|
|
|
|
all of dll's that windows uses are not inthe coorect form to use with VS.Net so we have to import them but i dont know how to extract the methods,object ,etc from them.in msdn there a few of them ...
help me...
|
|
|
|
|
|
|
Hi!
I am currently working on a tfmx (amiga sound format) player in c#. At the moment it reads correctly header and sound samples, macros and patterns.
But i don't have any idea how to output the audio files. Never wrote a music player but i can't rest till i finished this job.
I would really appreciate some help.
Greetings
|
|
|
|
|
|
You could also try using the latest version of Managed DirectX.
Playing audio with that is quite simple.
Try searching the articles for examples.
Kev
|
|
|
|
|
hello,
I made a simplest chatting application using UdpClient, it was working fine until I installed Win XP SP2. Now the messages are not being received at the other end. No Exceptions, nothing at all.
I even disabled the Windows Firewall that comes with SP2, still no hope. My application is still working fine on loopback, but nothing after it. I am using port 20052.
Can anyone explain what am I missing?
Regards,
Zishan
|
|
|
|
|
The reason may cause of security and firewall features avilable in XP SP2. What you can do is find out proper restriction areas where your client communicate with your requested machine.
And i recommand you to read more about Features and Techinical Overviews of SP2.
Learn About SP2
Techinological Overview This will give you some more ideas.
Techinical Look At SP2
Sreejith Nair
[ My Articles ]
|
|
|
|
|
Thanks for the reply.. yes it started working.. nice articles..
Regards,
Zishan
|
|
|
|
|
In my customer form there are few text box's for enter Data.i have set up sequence of tab no's for those text box's.What i want is to move cusor from
text field 1 to text field 2 by pressing Enter Key.
How can i do this by using c#.
Can any one Please Help me.
Amal
|
|
|
|