I'm familiar with the main Object Oriented concepts in programming and currently I'm teaching myself how to design classes.
I have a very simple class calld Company. Here's the code I have so far
using System;
namespace Addressbook
{
public class Company
{
private string _companyId;
private string _companyName;
private string _companyType;
private string[] _companyDetails;
public Company()
{
}
public string CompanyId
{
set
{
this._companyId = value;
}
}
public string CompanyName
{
set
{
this._companyName = value;
}
}
public string CompanyType
{
set
{
this._companyType = value;
}
}
public string[] GetCompanyDetails()
{
return null;
}
}
}
What I'm now trying to do is implementing some methods to it and that's where I'm sort of lost.
The first method I'm thinking of is called GetCompanyDetails()
which would gather data from a SQL database and then display it. Possibly in a DataGridView or something.
My problem is I can't figure out how I should write this method. Do I put all the SQL queries and connections inside it? Or do I just pass instances of them as parameters? What's the type I should return from the method?
Can someone please give me some guidelines on this?
And also, if you have links to any good tutorials/guides on this subject matter, please post them too.
Thank you.