|
Sounds like you're either P/Invoking the method wrong, or not passing the right parameter. Some code fragments (such as the P/Invoked method and the calling method) would help. Otherwise, you're not providing any information with which we can help you. Simply saying "it doesn't work" helps none.
Besides, you'd be better off asking this in the forum for that article, though asking here isn't exactly wrong (just that your question is specific to that article).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I know what are interfaces and what is the logic behind them, but I've never used them practically in any project.
Now I actually want to start incorporating them in my programms practically anc actually in a reasonable way.
I just want to know why should I use them instead of simply using classes? How are they useful when releasing new versions of our products?
Can you please provide me any link, where I can study and learn more about them? notice: practically
Regards!
|
|
|
|
|
I give you some point, you can't inherit from two class in C# but you can inherit from one class and as many as interface you waqnt. Is that enough reason forusing them in OOP world?
Mazy
"Improvisation is the touchstone of wit." - Molière
|
|
|
|
|
So, why interfaces are widely used in VC++, while it is possible to do multiple inheriting there?
|
|
|
|
|
They're great for writing plugins
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
Support Bone
It's a weird Life
|
|
|
|
|
|
- Interfaces lets you make multiple inherance.
The best examples are IList,ICollection,IEnumerate from the System.Collections namespace.
- Interfaces makes you focus on design before starting to actually do any coding. Ok, an example.
Consider you need to develop a product that manages customers, products and orders (classic example). Note that when starting to design the product, you do not know "implementation" details like how the data will be stored, etc...
The problem is sufficiently simple we don't have to go through UML and stuff but we can use interfaces to defines the relationships between the objects
public interface ICustomer
{
string Name {get;}
}
public interface IProduct
{
string Name {get;}
}
public interface IOrder
{
ICustomer Customer {get;}
IProduct Product {get;}
int Quantity {get;}
}
Here you can see the relationships between ICustomer, IProduct and IOrder. It is important to note that you have not written any "line of code" yet. You have just defined the objects. After that, you can implement the interface for database data, XMl file etc...
:=)
Jonathan de Halleux.
www.dotnetwiki.org
|
|
|
|
|
there's a couple reasons I use an interface. one of the biggest is so that I can write a function that can handle a generic reference of a class
here's an example I used it for
I created an ILookupTable interface that had methods like
Add(), Edit(), Delete(), SortUp(), SortDown() etc.
and then created several classes that implmented this interface
StateLookupTable,
TelephoneTypeLookupTable,
AddressTypeLookupTable
From there I could create one GUI that handled maintaining my lookup tables. When I needed to pass a class as a parameter, I would have a call like: public void MyCall(ILookupTable table)
and I knew I could call all of the properties and methods in that interface without actually having to know which particular class I was working with.
|
|
|
|
|
I have a two formed application in C#. I need to know how to get an integer from the initial form, to the second one.
|
|
|
|
|
What is the desired behavior of the two forms, i.e., what order will they be displayed, will the both be open at the same time, should one disappear...
Anyway, you might try passing the value from the first form to the constructor of the new form.
|
|
|
|
|
|
Something like this:
namespace FormConstructorParam
{
public class OverloadedConstructor : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
private int _value;
public OverloadedConstructor()
{
InitializeComponent();
}
public OverloadedConstructor(int someValue)
{
InitializeComponent();
_value = someValue;
}
}
}
then, when you create the instance of the form, you do this:
OverloadedConstructor oneForm = new OverloadedConstructor(1);
or this:
OverloadedConstructor anotherForm = new OverloadedConstructor();
|
|
|
|
|
The value could also be stored in a field or a property of either one or both of the forms...
|
|
|
|
|
Follow steps below:
1- Define a public or internal property inside your initial form(source class), which holds the integer value to send.
2- Define an overloaded constructor for the second form(destination class), which accepts an instance of the first form(i.e. Form1) as input parameter.
3- When instanciating the destination class(Form2), pass this keyword as input parameter to its constructor .
4- In destination class's constructor you have access the sourcr class's property, through this.PropertyName .
I hope this helps.
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
I'm sorry, i'm fairly new to this, could you give me an example?
|
|
|
|
|
I want to write a console application, Which will convert arabic numbers to roman.
But the problem is in roman 5000,10000 etc will be represented as V and a "-" symbol upon V..but i dont how to get these characters please let me know how to write a string a "-" upon them.
Please note that this is for console application
Its very urgent
|
|
|
|
|
Sounds like a class assignment for a computer science class...
GetOn&GetGoing wrote:
5000,10000 etc will be represented as V and a "-" symbol upon V
What do you mean, the fact that the roman numeral for five is a V with exaggerated serifs?
|
|
|
|
|
Ya i got it...
But how you will represnt 5000 you cant represent with "MMMMM", you should represnt as V and a "-" on that, i dont know how to print this kind of special characters in console application.
|
|
|
|
|
Ok, so a horizontal line over the roman numeral V is supposed to represent the fact that the number is multiplied by 1000. I think that that usage isn't really in vogue any more, but if it is necessary, how about writing an underscore ("_") on the line above the value?
|
|
|
|
|
Ya that will be fine with me...
But how to do that for a consle application
|
|
|
|
|
Ok, you know that you generate output in a console application with Console.Write() and Console.WriteLine() , right?
So, figure out which position of your roman number is the 1000's, then write an underscore on the line before you write the roman numerals:
Console.WriteLine("_");
Console.WriteLine("VCXIX");
|
|
|
|
|
Can any body send me the interview questions..I dont want direct questions
I wan the questions which are very tricky and concptual....
|
|
|
|
|
Try Programming Interviews Exposed (Mongan & SUojanen) published by Wiley.
|
|
|
|
|
I think you missed a forum hear
But if this is somehow C# related please be more specific!
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
CWIZO wrote:
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
LOL
|
|
|
|