|
I have three projects...
1) An interface definition dll as Project1.
2) An object definition dll as Project2.
3) A test application as Project3.
Class1 in Project2 implements the interface defined in Project1.
The test application uses Class1.
For some reason, I have to add a reference to the interface dll in both Project2 and Project3! I thought it would only be necessary to reference the interface in Project2, and that it would not be necessary to reference the interface in the application that uses Class1 in Project3.
Is this the expected behaviour?
|
|
|
|
|
Have you declared an interface pointer in Project3 code?
Best,
Jun
|
|
|
|
|
No... Project3 creates an instance of Class1.
|
|
|
|
|
Search the boards. I remember that the exact same question was asked not long ago.
---
b { font-weight: normal; }
|
|
|
|
|
Hi
I have a generic class: myclass<T> where I put T as either a float or a double. However whenever I compile I get the error:
Cannot convert type 'T' to 'float'
I know that any of the types I use can be converted to a float. How can I tell the compiler this?
thank you
|
|
|
|
|
You didn't give the code so I'm guessing here...
Did you do an exlicit cast?
myclass<float> x = new myclass<float>(5.6);
double y = (double)x.value;
If that fails, you could always do something uglier:
float z = x.value;
double y = (double)z;
|
|
|
|
|
Use the where clause to add a constraint to the generic type T , so that it has to implement the IConvertible interface. Afterwards you can use the ToSingle method to convert instances of the generic type T to Single (float ) type.
class myclass<T> where T : IConvertible
{
private void Test(T q)
{
float x = q.ToSingle(null);
}
}
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
|
Problem 1...
I now have the same problem, but the other way round. How can I convert a float to type T (which is either a float or a double and is iconvertible)?
I get the error:
Cannot convert type 'float' to 'T'
Problem 2...
The error:
Operator '*' cannot be applied to operands of type 'T' and 'T'
when I multiply two numbers
What can I do about this? Does float inherit from some class that defines basic mathematical operations?
All help is greatly appreciated.. I feel the end is in sight!!
thank you
|
|
|
|
|
Hi,
I have a documentstream that i get back from a Reporting Services Render. The stream is valid and holds that data of the report. I want to use this stream in the Webbrowser component so i use webbrowser1.DocumentStream = myStream. The problem is the webbrowser control shows nothing just a blank page. Is this a bug or should i do something else ?
Thanks in advance for any help !
|
|
|
|
|
hi all,
i'm trying to run a url that sends our username and password with a message with a number. This will then send a sms to the client's chosen number.
I tried to use: Process.Start(URL) but this opens the url in the web-browser.
Now i'm trying to figure out what this is doing.
HttpWebRequest Request;
StreamReader ResponseReader;
Request = ((HttpWebRequest)(WebRequest.Create(URL)));
ResponseReader = new StreamReader(Request.GetResponse().GetResponseStream());
Can somebody take a look at this code and try to explain what this particular code does? I saw it in an example but dont know if it is all i need to be able to run the url...
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
NarutoFan#1 wrote: HttpWebRequest Request;
Defines an object of type HttpWebRequest (in the System.Net namespace), but does not actually create the object.
NarutoFan#1 wrote: StreamReader ResponseReader;
Defines an object of type StreamReader (in the System.IO namespace), but does not actually create the object.
NarutoFan#1 wrote: Request = ((HttpWebRequest)(WebRequest.Create(URL)));
This line actually gets an HttpWebRequest object and places it into the variable defined in 1) above. It gets this object by a static call to the WebRequest.Create method. The WebRequest object can be found in the System.Net namespace.
NarutoFan#1 wrote: ResponseReader = new StreamReader(Request.GetResponse().GetResponseStream());
This line creates the StreamReader object defined in 2) above. It does so using one of the standard constructors on this object that takes a Stream (System.IO namespace) object. It gets this Stream object by a call to the HttpWebRequest.GetResponse method.
This code is pretty standard and you can trace through exactly what each line does by stepping over the code and reading the documentation for each object & method used.
|
|
|
|
|
how can i access controls from another form!??
lets say i have:
Form1
Form2 (listView1)
Form3
Form4 (button1)
what do i do so when ever i click button1 on form4 clears items in listview1!??
thank you!
It Is Not That I'm Different!
... I'm Only Making The Difference!
|
|
|
|
|
See this article about passing values between forms[^]. While the objective of the article is slightly different to your problem, the same techniques can apply.
|
|
|
|
|
can you please post some code...!??
i'm really new to C#...
thank you!
It Is Not That I'm Different!
... I'm Only Making The Difference!
|
|
|
|
|
Did you read the article? If so then I'd appreciate the opportunity to improve it. Could you tell me which part(s) you did not understand?
|
|
|
|
|
HI
Guys let me know one thing how to capture the data eneterd by the user through key baord in C# , e.g. if the user presses the A key of key board so i can access the A in my code for use, please consider guys i want to do this in windows service.plz reply ASAP,
thankx in advance
|
|
|
|
|
Are you trying to write a keylogger?
|
|
|
|
|
yup man , i want to get wht ever the user enters, my window services will be running at the back end,and all this task will be done by the windows services but how to capture the data entered by the user in windows service.
|
|
|
|
|
King Shez wrote: yup man , i want to get wht ever the user enters, my window services will be running at the back end,and all this task will be done by the windows services but how to capture the data entered by the user in windows service.
So you admit to seeking advice in writing a piece of spyware. A program that is illegal in many jurisdictions.
Clever.... Very clever.
|
|
|
|
|
No man , i am not hacker, it's just an assignment of my class , and i have just given the example man it was for understanding, i have to submit it next week man.
|
|
|
|
|
King Shez wrote: it's just an assignment of my class
What kind of school do you go to? Hacker School?!
|
|
|
|
|
This is the THIRD time you posted this question.
|
|
|
|
|
hi
i need an example how to open word document from C#
thanks Eyal
eyalso
eyalso
|
|
|
|
|
the EASIEST way to do so is simply running word.
System.Diagnostics.Process.Start("winword", "\""+filename+"\"");
winword runs word, while the filename in " is an argument with the filename you want to load.
the other way is to create a word object, for that you will need to add to reference a COM (to the toolbox) called "Microsoft Word Object Library" (something like that). there you will have an object that will allow to automate word (if that is what you want to do).
you can also download ms word tools for VS from microsoft's site.
|
|
|
|