I am new to C# and am porting an eMbedded VB project over to the VS.NET 2003. I am finding C# a far 'neater' language which strongly discourages 'spagetti' where VB is sometimes too inviting.
My query is this, I have established how to create a Class to provide static variables to my Windows application. The simple example is as follows:
1. Create a new Windows project and add a Class item (Class1)
2. Add a button (Button1) and a label (Label1) to the form
3. Add this following to the button1_Click event:
4. Replace all of Class1 with the following:
public class Class1
private static int Counter =0;
public int Resultant()
I then tried something along these lines:
Where myClass is declared in Form1. This is where I am a little perplexed.
a) Will the process of creating new class everytime I wish to return a property or call a method result in overheads if I called the (for example) had a loop that returned a value at processor speed. I guess I would simply declare the temporary instance and have my iterative loop afterwards.
b) Is there a way that I can declare myClass somewhere in Form1 and have it available through all of Form1
Thanks in advance from an enthusiastic newbie.