Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Post
Register
Login
2
Reply
Public object to be used in Form.
Song Lee
Dec 29 2014 7:00 PM
775
Reply
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
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
how to zip files in windows application c# vs2008
How To Create a Line Chart In Crystal Report C# Windows Form