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
Song Lee
NA
47
38.3k
Public object to be used in Form.
Dec 29 2014 7:00 PM
Hello, I got question about an assignment that I've been working on for weeks.
Teacher handed back to me, and said
m_contactRegistry
should not be public.
How will I fix this?
ContactManager class with m_contactRegistry:
class
ContactManager
{
public
List<Contact>
m_contactRegistry;
//declare object of the collection
public
ContactManager()
{
m_contactRegistry =
new
List<Contact>
();
}
/// <summary>
/// returns the count of m_contactRegistry
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public
Contact GetContact(
int
index)
{
if
(index < 0 || index >= m_contactRegistry.Count)
return
null;
return
m_contactRegistry[index];
}
Form.cs:
private void
dltButton_Click(
object
sender,
EventArgs
e)
{
string
currContact;
try
{ currContact = listBox.SelectedItem.ToString(); }
catch
(
Exception
) { return; }
foreach
(ContactFiles.
Contact
c
in
m_contactMngr.m_contactRegistry)
{
if
(c.ToString() == currContact)
{
m_contactMngr.m_contactRegistry.Remove(c);
break;
}
}
Thank you
Reply
Answers (
2
)
Datagridview
Unintended Function MonthName