TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
John Burns
NA
120
109.2k
splitting up an Initializer
Jan 4 2011 2:19 AM
hey again guys and thanks for all your support in the past questions.
this is just a question of prefference really and what way is best.
i made a simple class as i was working through my study book, a class called
Guy
i then came into the main
form 1
and then i made instances outside the form but inside the class so they can be accessed from any method in that form, the thing is though the initializers were split,
so rather than having my usual:
Guy john = New John();
i had it split in 2 parts like this:
public partial class Form1 : form
{
Guy john;
public Form1()
{
InitializeComponent();
john = new Guy
();
}
}
whay would they do this? the the book doesnt say so i tried to figure it out myself and came accross a discovery; the program will just fine i move the code about and join it back together like this:
public partial class Form1 : form
{
Guy john = new John();
public Form1()
{
InitializeComponent();
}
}
so the conculusion i came to is that it does not matter if the code is placed in 2 parts or as one line so that it can be accessed from the form in any method; it still does the same job. am i correct?
thanks
Reply
Answers (
7
)
[WINFORM] How to Capture Active Screen Inside MDI Container and save it as Image?
Read a list of nodes from xml file