managed code?
 




IT Certification FAQ

 
|
Home
|
Microsoft
|
CISCO
|
CompTIA
|
Exam/Study FAQ
|
Employment FAQ
| Links  | Forums  |
Book Reviews


FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  ProfileProfile  Log in to check your private messagesPrivate messages  Log inLog in

managed code?

 
Post new topic   Reply to topic    Forum Index -> microsoft.public.cert.exam.mcsd
Author Message
Edward
Guest





PostPosted: Mon Nov 22, 2004 3:34 pm    Post subject: managed code? Reply with quote

I was going through the examples in the C# book for 316. As a VB6.0, Fortran
and C++ programmer I was troubled by what I was doing. Below is a short
example I wrote to demonstrate my puzzlement.



Is this good coding in a managed environment? Just create new objects on the
heap and ignore them when you are done? Will they be taken care of when the
system does clean up? Shouldn't I destroy them myself?



for (int i = 0 ; i < 10; i++)

{

int p = new int();

p = i;

System.Console.WriteLine (place);

}





Thanks for the help



Edward
Back to top
Edward
Guest





PostPosted: Mon Nov 22, 2004 3:34 pm    Post subject: Re: managed code? Reply with quote

for (int i = 0 ; i < 10; i++)

{

int p = new int();

p = i;

System.Console.WriteLine (p); // forgot to change this variable to p also
Edward sorry

}

"Edward" <elongcore@news.net> wrote in message
news:O4rkCIK0EHA.1400@TK2MSFTNGP11.phx.gbl...
Quote:
I was going through the examples in the C# book for 316. As a VB6.0,
Fortran and C++ programmer I was troubled by what I was doing. Below is a
short example I wrote to demonstrate my puzzlement.



Is this good coding in a managed environment? Just create new objects on
the heap and ignore them when you are done? Will they be taken care of
when the system does clean up? Shouldn't I destroy them myself?



for (int i = 0 ; i < 10; i++)

{

int p = new int();

p = i;

System.Console.WriteLine (place);

}





Thanks for the help



Edward

Back to top
Nick
Guest





PostPosted: Tue Nov 23, 2004 10:33 am    Post subject: Re: managed code? Reply with quote

Yep, that should be ok afaik.

The difficulty comes when you are using types defined in unmanaged code.

Then you have to implement the dispose pattern and clean up after yourself.

"Edward" <elongcore@news.net> wrote in message
news:e7fDYOK0EHA.2528@TK2MSFTNGP10.phx.gbl...
Quote:
for (int i = 0 ; i < 10; i++)

{

int p = new int();

p = i;

System.Console.WriteLine (p); // forgot to change this variable to p also
Edward sorry

}

"Edward" <elongcore@news.net> wrote in message
news:O4rkCIK0EHA.1400@TK2MSFTNGP11.phx.gbl...
I was going through the examples in the C# book for 316. As a VB6.0,
Fortran and C++ programmer I was troubled by what I was doing. Below is a
short example I wrote to demonstrate my puzzlement.



Is this good coding in a managed environment? Just create new objects on
the heap and ignore them when you are done? Will they be taken care of
when the system does clean up? Shouldn't I destroy them myself?



for (int i = 0 ; i < 10; i++)

{

int p = new int();

p = i;

System.Console.WriteLine (place);

}





Thanks for the help



Edward



Back to top
Edward
Guest





PostPosted: Tue Nov 23, 2004 2:38 pm    Post subject: Re: managed code? Reply with quote

Well after years and years of cleaning up after myself, this managed code
just makes me nervous.


"Nick" <someone@somewhere.com> wrote in message
news:e$g9h9T0EHA.2568@TK2MSFTNGP11.phx.gbl...
Quote:
Yep, that should be ok afaik.

The difficulty comes when you are using types defined in unmanaged code.

Then you have to implement the dispose pattern and clean up after
yourself.

"Edward" <elongcore@news.net> wrote in message
news:e7fDYOK0EHA.2528@TK2MSFTNGP10.phx.gbl...
for (int i = 0 ; i < 10; i++)

{

int p = new int();

p = i;

System.Console.WriteLine (p); // forgot to change this variable to p
also Edward sorry

}

"Edward" <elongcore@news.net> wrote in message
news:O4rkCIK0EHA.1400@TK2MSFTNGP11.phx.gbl...
I was going through the examples in the C# book for 316. As a VB6.0,
Fortran and C++ programmer I was troubled by what I was doing. Below is a
short example I wrote to demonstrate my puzzlement.



Is this good coding in a managed environment? Just create new objects on
the heap and ignore them when you are done? Will they be taken care of
when the system does clean up? Shouldn't I destroy them myself?



for (int i = 0 ; i < 10; i++)

{

int p = new int();

p = i;

System.Console.WriteLine (place);

}





Thanks for the help



Edward





Back to top
Jon Goodwin
Guest





PostPosted: Tue Nov 23, 2004 5:36 pm    Post subject: Re: managed code? Reply with quote

Edward,
Have a look at the following URL:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/dotnetGCbasics.asp
It explains how .NET implements garbage collection and why you should
never need to worry about cleaning up after yourself again!

Edward wrote:
Quote:
Well after years and years of cleaning up after myself, this managed code
just makes me nervous.


"Nick" <someone@somewhere.com> wrote in message
news:e$g9h9T0EHA.2568@TK2MSFTNGP11.phx.gbl...

Yep, that should be ok afaik.

The difficulty comes when you are using types defined in unmanaged code.

Then you have to implement the dispose pattern and clean up after
yourself.

"Edward" <elongcore@news.net> wrote in message
news:e7fDYOK0EHA.2528@TK2MSFTNGP10.phx.gbl...

for (int i = 0 ; i < 10; i++)

{

int p = new int();

p = i;

System.Console.WriteLine (p); // forgot to change this variable to p
also Edward sorry

}

"Edward" <elongcore@news.net> wrote in message
news:O4rkCIK0EHA.1400@TK2MSFTNGP11.phx.gbl...

I was going through the examples in the C# book for 316. As a VB6.0,
Fortran and C++ programmer I was troubled by what I was doing. Below is a
short example I wrote to demonstrate my puzzlement.



Is this good coding in a managed environment? Just create new objects on
the heap and ignore them when you are done? Will they be taken care of
when the system does clean up? Shouldn't I destroy them myself?



for (int i = 0 ; i < 10; i++)

{

int p = new int();

p = i;

System.Console.WriteLine (place);

}





Thanks for the help



Edward






Back to top
clyclopedic
Guest





PostPosted: Tue Nov 23, 2004 10:40 pm    Post subject: Re: managed code? Reply with quote

I haven't watched it yet, but from the blurbs I think you might also be
interested in the Jason Zander interview posted to channel 9 today
http://channel9.msdn.com/

"Jon Goodwin" <jon@rocketwebservices.co.uk> wrote in message
news:OLIrYHY0EHA.3832@TK2MSFTNGP10.phx.gbl...
Quote:
Edward,
Have a look at the following URL:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/dotnetGCbasics.asp
It explains how .NET implements garbage collection and why you should
never need to worry about cleaning up after yourself again!

Edward wrote:
Well after years and years of cleaning up after myself, this managed code
just makes me nervous.


"Nick" <someone@somewhere.com> wrote in message
news:e$g9h9T0EHA.2568@TK2MSFTNGP11.phx.gbl...

Yep, that should be ok afaik.

The difficulty comes when you are using types defined in unmanaged code.

Then you have to implement the dispose pattern and clean up after
yourself.

"Edward" <elongcore@news.net> wrote in message
news:e7fDYOK0EHA.2528@TK2MSFTNGP10.phx.gbl...

for (int i = 0 ; i < 10; i++)

{

int p = new int();

p = i;

System.Console.WriteLine (p); // forgot to change this variable to p
also Edward sorry

}

"Edward" <elongcore@news.net> wrote in message
news:O4rkCIK0EHA.1400@TK2MSFTNGP11.phx.gbl...

I was going through the examples in the C# book for 316. As a VB6.0,
Fortran and C++ programmer I was troubled by what I was doing. Below is
a short example I wrote to demonstrate my puzzlement.



Is this good coding in a managed environment? Just create new objects
on the heap and ignore them when you are done? Will they be taken care
of when the system does clean up? Shouldn't I destroy them myself?



for (int i = 0 ; i < 10; i++)

{

int p = new int();

p = i;

System.Console.WriteLine (place);

}





Thanks for the help



Edward







Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> microsoft.public.cert.exam.mcsd All times are GMT
Page 1 of 1

 

Copyright © 2002-2006 Web-S-Sense Pty. Ltd. All rights reserved.

Powered by phpBB
Advertising | Policies/Disclaimers | Contact us | Link to us


Featured Sites: Free Antivirus and Antispyware Info | Free PC Support | MCSE Directory