|
Hi,
the way you go about this seems wrong to me. You have four different kinds of objects,
so there should be four classes, probably all deriving from one common class, say:
class Shape { ... }
class Rect : Shape { ... }
class ZShape : Shape { ... }
class LShape : Shape { ... }
class LongShape : Shape { ... }
Now put common methods in Shape, and specific ones in the specific classes; then
create a new shape whenever you need one by instantiating the right class.
In this way, you never need to copy or clone an existing object.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Im trying to access a listbox control located on my main form inside an AsyncCallback method and getting cross thread errors as AsyncCallback is on a seperate thread. I decided then to create a new delagate and fire an event from within the AsyncCallback method thinking this would solve the problem but that too was executed on a seperate thread.
How can i fire an event from inside the method that runs on the main thread?
thankyou.
|
|
|
|
|
Hi,
as always, GUI components need to be handled by the GUI thread; COntrol.InvokeRequired,
and Control.Invoke() take care of that. There are plenty of examples everywhere.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Yes
exactlly.
use the any control.invoke() for that.
Cheers
RRave
MCTS,MCPD
|
|
|
|
|
I have about 200+ songs in my library but they're only sorted by artist. I want to have it sorted by Artist then by Album. I googled and I can't find anything on how to get special attributes of a file like mp3's. Does anyone know how I would do this is C#?
Thanks.
|
|
|
|
|
There are a number of classes for reading ID3 tag information about on the web. I used one ages ago, in .NET 1.1. It supported id3V1 ( which is trivial, the data is just on the end of the file ) and if3V2 ( which is not, the data is compressed on the end of hte file )
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Check out TagLib#. It probably supports more filetypes than you need, but it was made to do exactly what you're looking for.
|
|
|
|
|
All right thanks man. I'm gonna archive this for future use.
modified on Saturday, February 16, 2008 2:25 PM
|
|
|
|
|
I have the following class:
class Foo<T> where T : EventArgs { } Now I have an object and I want to see if it's a type Foo<?> (that is, a Foo<Anything> ). How do I do this?
bool isAFoo = someObject is Foo<>;
|
|
|
|
|
Hi Judah,
this compiles, and might be what you want:
class Foo<T> where T : EventArgs { }
class test {
private void aha() {
Foo<MouseEventArgs> mea=new Foo<MouseEventArgs>();
bool isFoo=mea is Foo<EventArgs>;
}
}
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
While it compiles, isFoo == false, which isn't what I was looking for.
|
|
|
|
|
Judah Himango wrote: While it compiles, isFoo == false, which isn't what I was looking for
SO there is an improvement, a minor one at that
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
The only way to do that would be to get the type name as a string, and examine it. Two types derived from the same generic type are still two completely different types, there is no grouping of types.
Why do you want to know if the object is derived from a specfic generic type? You still can't use the object for anything based on that information. You have to cast the object to some specific class or interface to be able to do anything with it except what the Object class provides.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Guffa wrote: The only way to do that would be to get the type name as a string, and examine it.
I was able to do a little better. someObj.GetType() == typeof( Foo<> ) actually works.
Guffa wrote: Why do you want to know if the object is derived from a specfic generic type? You still can't use the object for anything based on that information.
Indeed, sounds like we have a design flaw. Thanks for your input.
|
|
|
|
|
|
Swap the parameters, you have them in the wrong order.
client = new Client(sm, sc, txtThread2, btnStart, btnStop);
client = new Client(sc, sm, txtThread2, btnStart, btnStop);
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
hi,
please can you help me to create my own xmp in an existing pdf document with C#.
Thanks
|
|
|
|
|
What is an xmp ?
You'll need to buy or find a library that works with PDFs.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello, Can someone tell me how I can display local current date and time from user's machine, not server's time, using C#? I am developing a web form that when accessed by user will display his local time. Basically I am looking for the Javascript equivalent of GetCurrentDateTime(). The format I will need is 2/15/2008 1:38 PM. Any help is appreciated. Thanks!
|
|
|
|
|
|
Hello, Sorry for typo. I meant to say I am looking for the C# equivalent of GetCurrentDateTime() (javascript function).
|
|
|
|
|
tjkota wrote: date and time from user's machine, not server's time
So you do want the servers time?
tjkota wrote: date and time from user's machine, not server's time
led mike
|
|
|
|
|
hi, no, I don't want server time. I want machine time that can be obtained using Javascript's GetCurrentDateTime(). Can you suggest a way to obtain the same using C# or suggest a way to pass Javascript value to C# server?
|
|
|
|
|
What is this some sort of joke?
tjkota wrote: suggest a way to pass Javascript value to C# server?
tjkota wrote: I am developing a web form that when accessed by user will display his local time.
One does not need to get the time in Javascript from the Browser to send it to the server to display it in the Browser. If you figure out what you actually need that makes any sort of sense maybe you can let us know.
led mike
|
|
|
|
|
Okay, Mike, here is what I need. I will need to display on my form each visitor's respective date and time. I kind of know that this can only be achieved by a client-side script like Javascript (eg, GetCurrentDateTime()).Upon submission of the form I am exporting the html form to word document and sending as an attachment. When I export form to word, the date time value loaded by Javascript (on a label) doesn't get exported, strangely. I will need to figure out a way to pass the datetime value from javascript to ASP.NET and then display it on the form. This will then surely get exported to word. I hope this makes sense. Thanks.
|
|
|
|