PC Review


Reply
Thread Tools Rate Thread

Const object takes memory?

 
 
Tomer
Guest
Posts: n/a
 
      22nd Dec 2004
Hi,
When I define a const, does it takes memory in run time, or does the
compiler replace the code where I've used the const var, and then compile
the program?

Tomer.


 
Reply With Quote
 
 
 
 
Daniel Moth
Guest
Posts: n/a
 
      22nd Dec 2004
The compiler should replace the constant's value in the IL wherever the
const variable is used. Just compile your code with and without the const
keyword and observe the differences in IL using ILDASM

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


"Tomer" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi,
> When I define a const, does it takes memory in run time, or does the
> compiler replace the code where I've used the const var, and then compile
> the program?
>
> Tomer.
>
>



 
Reply With Quote
 
Tomer
Guest
Posts: n/a
 
      22nd Dec 2004
Thanks!

Tomer.


"Daniel Moth" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> The compiler should replace the constant's value in the IL wherever the
> const variable is used. Just compile your code with and without the const
> keyword and observe the differences in IL using ILDASM
>
> Cheers
> Daniel
> --
> http://www.danielmoth.com/Blog/
>
>
> "Tomer" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Hi,
> > When I define a const, does it takes memory in run time, or does the
> > compiler replace the code where I've used the const var, and then

compile
> > the program?
> >
> > Tomer.
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
This delegate takes ParameterizedThreadStart takes an object but can be called wirhout parameter Tony Johansson Microsoft C# .NET 2 12th May 2010 04:35 PM
How to pass a const object (read only object) to a method? raylopez99 Microsoft C# .NET 7 6th Jul 2008 12:22 PM
Checking how much an object takes in memory =?Utf-8?B?UmFuIERhdmlkb3ZpdHo=?= Microsoft Dot NET 0 29th Mar 2005 04:19 PM
defining a const color object Claire Microsoft C# .NET 1 26th Jul 2004 10:40 AM
Const Object Reference in C# function Shreyas Ranade Microsoft C# .NET 3 5th Sep 2003 06:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:39 AM.