|
um... you can put both in the same using statement parens.
so it becomes
using(
Font f1 = new File(..),
Font f2 = new File(..)
) {
// do your thang
}
|
|
|
|
|
Wow, I never knew that. Thanks.
But still C++ detructor stuff is far better.
|
|
|
|
|
Andy Smith wrote:
using(
Font f1 = new File(..),
Font f2 = new File(..)
) {
Actually you can't quite do that.
If you have multiple variables of the same type it will work, but you need to omit the second "Font"; so it becomes using(Font f1 = new Font(...), f2 = new Font(...)) .
If you wish to declare two different types you can do that as well; but you need to use two using statements.
using(Font f1 = new Font(...))
using(FileStream file = new FileStream(...))
{
...
} That's a lot of elipsis
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
oh, ya, thanks for the correction.
still better than the alternative.
|
|
|
|
|
|
Hi
I dont even know how to start asking what I want to know.
1. I assume these are only for variables (objects, whatever) that is needed in a global scope. My understanding is that if you declare and create a new object within {} it will be disposed/finalized automatically when the {} ends.
Is my understanding correct?
2. If correct, does the above post refer to disposing/finalizing global variables when they no longer needed, in case they taking up too many resources?
3. Now I'm too confused what the hell I wanted to know
I think I'll go read up on it some more.
PS: Can someone perhaps explain with a realworld / code why it should be used and where specifically.
READ MSDN
|
|
|
|
|
your understanding on 1 is incorrect.
the variable may go out of scope at the end of a block, but that does not mean that the GC will immediately collect it. The GC collects memory on its own schedule.
|
|
|
|
|
thx, some reading made me understand some more ( i somehow understand MSDN english better than some of the people's posts here ).
to sum it up:
u would only use the using statement when u need to immediately free up resources, if so desired, else the GC will take care of it in its own time.
READ MSDN
|
|
|
|
|
Hi!
Can I use OpenGL from C#?
If yse how do I do it? Can I get an example?
Thanks
Ilan Ehrenfeld
|
|
|
|
|
|
Nice link
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
|
Hello,
I want to use containers that are feature rich and have corresponding iterators that can modify the object on the fly. Also, I would like to have at my disposal a set of common algorithms that I can use with the containers/iterators. I was wondering if there is anything like that out there besides the .NET Framework Collections that I can use. Can anyone recommend any library that is available?
Thanks.
|
|
|
|
|
Is this a troll ? You're describing the STL, and it's not available in C#.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Remember that amateurs built the ark. Professionals built the Titanic.
|
|
|
|
|
You are right that something like STL is not available in the .NET Framework, and that is why I posted a simple question here to find an alternative. I need something to do dynamic data processing, and the Collections API does not cut it.
|
|
|
|
|
Doesn't ArrayList or other collection class meet your requirement?
I'm amumu, and you?
|
|
|
|
|
As a collection, I can get by with ArrayList, but I also need to utilize varies algorithms dynamically to operate on the values in the ArrayList. Is there a way to do this with .NET besides writing my own, or is there a library available that I can use?
|
|
|
|
|
I believe you CAN specify sorting algorithms for ArrayList ( what a dumb name - is it an array, or a list ? ), but beyond that, you're on your own.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
If the object you stored in Array implements the IComparable interface, you can use Array.Sort to sort the elements by your own algorithms.
I'm amumu, and you?
|
|
|
|
|
Hello
I newbie in C#. can anybody help me with such problem as changing color of item in ListBox by clicking on item.
Thanks in advance
|
|
|
|
|
|
Hello guys!
Is there any advised method to browse for a folder in C#?
Should I import the SHBrowseForFolder Api or is there a more convenient and .NET only way?
Cheers
Martin
"Situation normal - all fu***d up"
Illuminatus!
|
|
|
|
|
Martin `Lucanus cervus` wrote:
Should I import the SHBrowseForFolder Api or is there a more convenient and .NET only way?
Yes
But Rama has already done all the hard work for you.
See :- http://www.codeproject.com/cs/miscctrl/folderbrowser.asp
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Nishant S wrote:
See :- http://www.codeproject.com/cs/miscctrl/folderbrowser.asp
Thanks for the link Nish
I look forward to read the article.
Cheers
Martin
"Situation normal - all fu***d up"
Illuminatus!
|
|
|
|
|
hi
I want to transfer data from one Process to other process. My data is the Sring value. Ho can I ?
VIKS
|
|
|
|