static keyword
- From: josh <xdevel1999@xxxxxxxxx>
- Date: Tue, 29 Jan 2008 07:47:39 -0800 (PST)
Hi, if I want to use these following code I got a compiler error:
public Log()
{
Form1 f = new Form1();
static printLogTo()
{
f.textEdit1.Text = "some error...";
}
}
I understand that I cannot use f as when I call Log.printLog() f has
not been created so f has not an instance of
its class.
So how can I instantiate f for using in my static method?
P.S.
In Java I can do:
static
{
// some instructions will be executed here...
}
.
- Follow-Ups:
- Re: static keyword
- From: Arne Vajhøj
- Re: static keyword
- From: Ignacio Machin \( .NET/ C# MVP \)
- Re: static keyword
- From: Nicholas Paldino [.NET/C# MVP]
- Re: static keyword
- From: Jon Skeet [C# MVP]
- Re: static keyword
- Prev by Date: Re: How to call Vbscript functions in C# application
- Next by Date: Re: ho to add reference to MAPI?
- Previous by thread: Re: How to call Vbscript functions in C# application
- Next by thread: Re: static keyword
- Index(es):