Click here to Skip to main content
15,920,383 members
Home / Discussions / C#
   

C#

 
GeneralRe: Focus and Button Pin
oOomen26-Oct-03 20:29
oOomen26-Oct-03 20:29 
GeneralCommand Promt window Pin
livss26-Oct-03 3:26
livss26-Oct-03 3:26 
GeneralRe: Command Promt window Pin
Ark26-Oct-03 4:08
Ark26-Oct-03 4:08 
GeneralDirectX and System.Math Pin
Ark26-Oct-03 2:56
Ark26-Oct-03 2:56 
Generalstatic constructors Pin
R. Thomas26-Oct-03 0:55
R. Thomas26-Oct-03 0:55 
GeneralRe: static constructors Pin
Blake Coverett26-Oct-03 2:10
Blake Coverett26-Oct-03 2:10 
GeneralRe: static constructors Pin
R. Thomas26-Oct-03 2:24
R. Thomas26-Oct-03 2:24 
GeneralRe: static constructors Pin
Blake Coverett26-Oct-03 2:39
Blake Coverett26-Oct-03 2:39 
Yup.

Though C# does have a convenient feature of creating constructors for you based on variable initialization statements. This is particularly handy with static constructors. For example, the following two pieces of code are almost equivalent.
class Foo {
    static int Bar = 42;
}

class Foo {
    static int Bar;
    static Foo() {
        Bar = 42;
    }
}


Aside from being less typing, it turns out that the first syntax is a little more efficient as well. The reason why is complicated and I won't try to cover it here, but if you are curious you can google for 'beforefieldinit'.


-Blake
GeneralRe: static constructors Pin
R. Thomas26-Oct-03 3:46
R. Thomas26-Oct-03 3:46 
GeneralRe: static constructors Pin
Blake Coverett26-Oct-03 4:09
Blake Coverett26-Oct-03 4:09 
GeneralRe: static constructors Pin
Heath Stewart26-Oct-03 5:58
protectorHeath Stewart26-Oct-03 5:58 
Generalstack and heap Pin
R. Thomas26-Oct-03 0:49
R. Thomas26-Oct-03 0:49 
GeneralRe: stack and heap Pin
Blake Coverett26-Oct-03 2:27
Blake Coverett26-Oct-03 2:27 
GeneralRe: stack and heap Pin
R. Thomas26-Oct-03 2:38
R. Thomas26-Oct-03 2:38 
GeneralRe: stack and heap Pin
Blake Coverett26-Oct-03 3:31
Blake Coverett26-Oct-03 3:31 
GeneralRe: stack and heap Pin
R. Thomas26-Oct-03 3:44
R. Thomas26-Oct-03 3:44 
GeneralRe: stack and heap Pin
Blake Coverett26-Oct-03 3:55
Blake Coverett26-Oct-03 3:55 
Generalremainder Pin
R. Thomas26-Oct-03 0:40
R. Thomas26-Oct-03 0:40 
GeneralRe: remainder Pin
leppie26-Oct-03 0:51
leppie26-Oct-03 0:51 
GeneralRe: remainder Pin
R. Thomas26-Oct-03 0:53
R. Thomas26-Oct-03 0:53 
GeneralRe: remainder Pin
Rakesh Rajan26-Oct-03 1:08
Rakesh Rajan26-Oct-03 1:08 
GeneralRe: remainder Pin
Daniel M. Edwards26-Oct-03 1:11
Daniel M. Edwards26-Oct-03 1:11 
GeneralRe: remainder Pin
R. Thomas26-Oct-03 1:16
R. Thomas26-Oct-03 1:16 
GeneralRe: remainder Pin
Daniel M. Edwards26-Oct-03 1:17
Daniel M. Edwards26-Oct-03 1:17 
GeneralType.GetMembers() Pin
Arun Bhalla25-Oct-03 15:02
Arun Bhalla25-Oct-03 15:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.