|
not at all!!!!
my argument was not that whether the using is a pattern or not
I said, saying - "using is not pattern and cant be compared with other pattern" is wrong!!!!!! [only because its not a pattern]
|
|
|
|
|
So it's a technique, what of it?
|
|
|
|
|
SaveTigers wrote: I just wanted to see if there are some other differences other than which I have mentioned!
Points mentioned by you are correct. It all depends on your object's lifetime. You can use using block when your object have very small lifetime, say in a function.
Consider the example 1 provided in your first post. I assume you have your word wrapper class used in a windows form.
class WordOperations : Form
{
WordWrapper wrapper =
protected override void Dispose(bool disposing)
{
wrapper.Dispose();
}
} In the above example, we have used form's dispose method to dispose your word wrapper. This will help you to *avoid* the finalization. Now a user of your form can use it like
using(WordOperations op = new WordOperations())
{
op.ShowDialog();
} This will ensure the disposal of form and the wrapper.
Finalization has a cost and try to avoid it when possible. So, if you own the code base, there is no need to implement a finalizer on the wrapper class. Just make sure you call Dispose() .
SaveTigers wrote: Apart from that, what exactly pattern? its only some set of standard which anybody can define( with some advantage), so saying something like this that Using is not pattern and cant be compared with Dispose/Finalize pattern will be a harsh!! isn't it?
No.
Implementing IDisposable in a recommended way is called as dispose pattern. using is just a syntactic sugar to ease the use of disposable objects. Read Implementing IDisposable and the Dispose Pattern Properly[^] to get a good understanding about this.
|
|
|
|
|
Thanks Navaneeth for your reply !!
|
|
|
|
|
I want to store two keys and one value associated with those keys in an object and want to send that object to some method.
As hash table can have key value pair,What is the way to do this??
|
|
|
|
|
You can use a <code>Dictionary</code> object with key set as an array. Something like this:
<pre>Dictionary<string[], string> oDictionary = new Dictionary<string[], string>();</pre>
modified on Friday, July 31, 2009 3:01 AM
|
|
|
|
|
A Dictionary of Dictionaries?
Or write a class to contain the two keys.
Lots of ways.
|
|
|
|
|
|
If you want to reuse existing types, you can use a Dictionary<KeyValuePair<K1, K2>, T> , where K1 and K2 are the types of the two keys you want to use and T is the type of the value you want to use.
Hopefully, the introduction of tuples in .NET 4.0 will make all this more easy.
|
|
|
|
|
So, i'm very new to this site and programming in general. So far i've made just a hex/decimal convert. Well, some of you may be familiar with "CoD Tool" that is used to modify xbox 360 games. I want to make a program like this, but I need some stuff answered.
1. I need to know how to search for a specific string in a file (may be hex string"
2. I need to go so many bytes after the found string.
3. I need to insert, delete, and replace what was found with something else (has to be edited with hex)
For those that don't know, i need to put a "." but change the hex to something like "09" or "12"
|
|
|
|
|
craigchrist8239 wrote: 1. I need to know how to search for a specific string in a file (may be hex string"
Using Regular expression. You can find help regarding regular expressions on this[^] site.
craigchrist8239 wrote: 2. I need to go so many bytes after the found string.
Not sure what do you mean by this.
craigchrist8239 wrote: 3. I need to insert, delete, and replace what was found with something else (has to be edited with hex)
File.ReadAllLines and File.WriteAllLines method would do that. AFAIK, you cannot edit a file. You will need to read entire file and then write entire file again.
|
|
|
|
|
Thx for this, i'll look into it, but, what I mean by go so many bytes after a found line is...
What 1 thing you do is search for C1C8F1 in hex, then go E6 bytes past the C1C8F1 and thats what you have to edit. You do that because what you have to edit isn't the same every time.
|
|
|
|
|
In that case, File.ReadAllBytes and File.WriteAllBytes will be good for you. Not sure though.
|
|
|
|
|
I'm writing an application file copy, but do not know how to get the source folder and target folder when copying the explorer (ie: when a user R_Click and select Copy, Past the windows explorer and I want to take the path of this directory)
Thanks !!!
|
|
|
|
|
If you see the "Main" method, it looks like this :
static void Main(string[] args)
You get the directory in "args".
Just use args[0] and args[1]
|
|
|
|
|
Hi,
kindly let me know, How may I change back color in LISTBOX of any particular item or index ?
Thank you
(Riaz)
|
|
|
|
|
You can do that by handling DrawItem event of the ListBox. Make sure you set the DrawMode as OwnerDrawFixed or OwnerDrawVariable as per your needs.
|
|
|
|
|
|
I want to draw a graph similar to microsoft project plan which shows tasks (start & completion date for each task) and dependency like if start of any task is dependent on completion of other tasks.
To start with i need some guidance. I searched in google and i found ZedGraph but it does not solve my requirement. Please help
|
|
|
|
|
If you look at the source code for zedGraph, that may help a lot. Basically you handle a paint event and you write code to draw your graph.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
Just like DrawLines can draw hundreds of thousands of lines at once, hell lot better performance than going through loop and drawing each individual line.
I want something similar for ellipse as well..Going through loop is making my app really sluggish..
Pl help
|
|
|
|
|
Unlike Graphics.DrawLines, there is no equivilent DrawEllipses. You have no choice but to loop through each ellipse you want to draw.
|
|
|
|
|
I'm working on windows application.I need to find out the number of bold letters available in the Word document.
I have used name space Microsoft.Office.Interop.Word to read the word document and also tried with some of the properties like Selection,Range to find whether the character is in bold or not but no result.
I have read each character by reading the content of document and checking its format but here while reading the text the character is missing its Format.
I have also tried by converting it into html format and tried by using HTML Element Collection but it is unable to read/recognize the bold tag.
Please give the solution to count the bold letters of word document.
Thanks
|
|
|
|
|
This[^] wasn't good enough?
|
|
|
|