|
If you are its uncle, I'm its cousin twice removed.
TIL the c++ destructor syntax is valid in c#
|
|
|
|
|
"Empty destructors should not be used. When a class contains a destructor, an entry is created in the Finalize queue. When the destructor is called, the garbage collector is invoked to process the queue. If the destructor is empty, this just causes a needless loss of performance." - http://msdn.microsoft.com/en-us/library/66x5fx1b.aspx
TY!
|
|
|
|
|
Destructors are not magic and do not automatically clean up your resources by just putting the placeholder code there. If you allocate unmanaged objects YOU must un-allocate them.
However, I would advise reading up on the differences between using a destructor versus implementing IDisposable. Destructors in C# are very different than those in C++ and understanding when they are called and what they do is important in how you effectively use them.
See this StackOverflow answer[^] on using IDisposable and finalizers.
Note how the proper use of IDisposable helps you since you, the programmer, have almost no control when the finalizers are run, and absolutely no control about what order they run in (finalizers for unreferenced objects are not guaranteed to run in any particular order, and this could be important).
|
|
|
|
|
To be fair if you do not know how to use correctly create and use IDisposable then it will be just a bad as a destructor.
|
|
|
|
|
In general, you should not need to add destructors to your code.
You can explore the Dispose method.
|
|
|
|
|
WidmarkRob wrote: I also understand you put it inside your class at the very bottom preceded with a tilde, same name as the class… No modifiers of any kind. It doesn't have to go at the bottom. In C#, the way you order your methods has no effect on the way your code performs at run time.
In general, I'm not a big fan of finalizers. Finalize objects are treated differently to objects without finalizers, even if you dispose of the object and call GC.SuppressFinalizer() . Have a read about the freachable queue here[^].
|
|
|
|
|
I disabled Lazy Loading for various reasons (Mostly proxy craziness and performance) but I have hit a snag I don't know how to handle.
I have an address table that has a street address broken into parts. One of the pieces is a SuffixId that determines if it is a street, ave, etc... Here is my fullAddress property of the address:
public string fullAddress
{
get
{
string address = number.ToString();
if (direction != null)
address += " " + direction;
address += " " + street;
if (suffixId != null)
address += " " + StreetSuffix.abbreviation;
return address;
}
}
Now my problem is with the StreetSuffix.abbreviation part, I am getting a null reference. How do I handle this?
Cheers, --EA
|
|
|
|
|
Why are number, direction and street also notnull. Because you load the information somewhere. I suspect you are not loading the StreetPrefix record.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
As usual, you are correct. Forgot to include the StreetSuffix in the Get.
Cheers, --EA
|
|
|
|
|
My client has asked me to incorporate text messaging into an app I'm working on. I've never done this before.
1) Do I need to set something up on their server?
2) What's the code look like for this? I've been Googling but found a lot of different samples.
Can someone point me in the right direction?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
A lot depends on what you are doing, at a basic level you'll need an SMS service. If you are doing bulk SMS work you'll need to google SMS providers and find ones that provide an API, I found results googling "sms api" though that'd take a fair bit of digging to get the best deal based on your usuage.
If you need something lower-end, some phones act like modems when connected via USB and provide the functionality google "send sms from my phone connected to pc" and you'll get some joy. It looks like Android plays with this sort of thing really well.
I've not done this sort of work, but I have seen both the above in operation.
|
|
|
|
|
Hello,
How can I use WM_PASTE to send a plain text from clipboard to the active window and the focused textbox/combobox ?
----------
I want to paste by double-Click, I can detect the double click event and execute a code when it done
so the destination window will be active the textbox/combobox will be focused
please provide me a little sample project working with a timer in background and do the paste command.
I keep searching for a solution to this problem for days but no results
-------------------
Thanks
JusT LeT YouR MinD WorK
|
|
|
|
|
WM_PASTE is the message sent to the Window in which Paste operation takes place.
Refer: Link[^]
|
|
|
|
|
I understand this
all what I need is a simple example to know how to do it
JusT LeT YouR MinD WorK
|
|
|
|
|
This message must be handled by the receiving window. When you receive a WM_PASTE [^] message, it is your responsibility to deal with it. You should generally read the contents of the clipboard and past them onto your window, or wherever else your program wishes.
Veni, vidi, abiit domum
|
|
|
|
|
I assume, since you posted on this Forum, you are using C# ... correct ?
Please state in what context you are using C#: WinForms ? WPF ? SilverLight ? ... ?
Whatever you are using: what is it that you double-click on that triggers the Paste Event into the "destination window ... active ... textbox/combobox" ?
Are you saying you want to detect a double-click Event anywhere in your application's main window, or in its child controls ? Does that imply you want to disable the standard double-click functions that occur in certain controls, like a TextBox ?
Not a good idea.
If you double-click on a WinForm the focus of the application may change, depending on what you clicked on; there may be no active Control. For example, if I have a TextBox and a PropertyGrid on a WinForm: if the TabOrder is set so that the TextBox is the Control with Focus when the application starts, then if I click on the PropertyGrid there is no active control on the Form. However, if I double-click on the Form itself, then Form.ActiveControl will still retain its last valid setting.
I doubt anyone here is psychic enough (unless OriginalGriff is here) to figure out what the role of a Timer is in whatever you are trying to build.
If you take the time to describe your problem in detail, I do think we can help you search more "smartly," however. You may be "spinning your wheels" right now as a result of "trying too hard:" that happens to me
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview
|
|
|
|
|
I refuse to remove my tin-foil hat for this one!
The only instant messaging I do involves my middle finger.
|
|
|
|
|
I have no problem with double-click event it is already working without any problem
All what I need is to paste from clipboard to the active window and the focused textbox
I tried SendMessage and PostMessage but it is not working with me
JusT LeT YouR MinD WorK
|
|
|
|
|
|
I would like to know where to find the OOPS/design patterns and principles discussion in code project, or is there any in here?
Thanks,
[More information] : I was looking for something like this:
^http://stackoverflow.com/questions/tagged/solid-principles[^]
anyways thanks for the responses people!
modified 1-Oct-13 11:25am.
|
|
|
|
|
OOPS and design patterns are different concepts. What's to discuss, outside of the definition the Wiki gives and the well-known patterns?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You are going to be better off either using the search built into code project than asking here.
Ass Eddie says, OOP and design patterns are different concepts. You get design patterns for non-OO languages, though good OO-based design patterns help you adhere to OOP.
You might want to search for the "Four Pillars of OO", there is a lot of stuff out there about this. You should learn, and more importantly understand, what they are, what they mean and how this expresses itself in your chosen language. You'll save yourself a world of pain and spaghetti code in the future if/when you manage this.
Design Patterns generically are well-know (and defined) solutions to common problems. Really the pattern is a name given to such a thing,so we can discuss this as shorthand. The chances are you've actually used or implemented a pattern without knowing it. For example,c# events are an implementation of the observer pattern, so if you used an event you've unwittingly used an observer patter, There are lots of these patterns (and pseudo-patterns and anti-patterns) on the net - find out which the common ones are, and implement them.
|
|
|
|
|
If you are looking for articles on OOPS just do a search here[^]. It should give you tons of information to sift through.
|
|
|
|
|
Am sorry for not being clear, I meant to say OOPS, Design principles and pattern. My intention was not to link OOPS with design patterns though. Anyways thanks to Abhinav S for sharing the link to search page.
The intention of this question is to find any forum topic to go through some real-world issues faced on these concepts (wrong usage I mean) and the discussion about how to solve those, rather than going through the tutorials on Dog, cat, apple, mango, etc.
|
|
|
|
|
justgovi wrote: to go through some real-world issues faced There is no list of specific problems that get solved using OOPS/design patterns. You're looking at dishes where you can use a fork, while you should study the fork - that way you'll be able to explain why soup won't work, even without having a pointer to a previous real life pain.
..and we do have articles on various patterns that use "real world" examples. Yet, that's what they are; examples. An example of a for-loop does not show where a for-loop would be beneficial (compared to a while loop), it doesn't convey the abstract idea.
As for the OO-principles, they're general guidelines. Each of those guidelines comes with a reasoning.
justgovi wrote: wrong usage I mean Google for the anti-patterns and you'll find them; God objects, ravioli-code and much more.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|