Click here to Skip to main content
15,899,754 members
Home / Discussions / C#
   

C#

 
GeneralRe: horizontal scroll bar move event... Pin
spalanivel28-Jul-09 22:00
spalanivel28-Jul-09 22:00 
GeneralRe: horizontal scroll bar move event... Pin
spalanivel29-Jul-09 0:53
spalanivel29-Jul-09 0:53 
AnswerRe: horizontal scroll bar move event... Pin
Alan N29-Jul-09 2:03
Alan N29-Jul-09 2:03 
QuestionOOP approach, static method Pin
Raybarg28-Jul-09 20:46
professionalRaybarg28-Jul-09 20:46 
AnswerRe: OOP approach, static method Pin
Christian Graus28-Jul-09 21:00
protectorChristian Graus28-Jul-09 21:00 
AnswerRe: OOP approach, static method Pin
DaveyM6928-Jul-09 22:41
professionalDaveyM6928-Jul-09 22:41 
GeneralRe: OOP approach, static method Pin
Raybarg28-Jul-09 23:04
professionalRaybarg28-Jul-09 23:04 
GeneralRe: OOP approach, static method Pin
DaveyM6928-Jul-09 23:39
professionalDaveyM6928-Jul-09 23:39 
It depends - not very helpful I know!

If they need array elemement level access then probably yes.

Imagine if your document was basically a header, body and footer - all strings. Something like this would be a good way of exposing it.
public class TheDocument
{
    private string[] theData = new string[3];

    public TheDocument()
        : this(new string[] { string.Empty, string.Empty, string.Empty })
    { }
    public TheDocument(string body)
        : this(new string[] { string.Empty, body, string.Empty })
    { }
    public TheDocument(string header, string body)
        : this(new string[] { header, body, string.Empty })
    { }
    public TheDocument(string header, string body, string footer)
        : this(new string[] { header, body, footer })
    { }
    // This constructor is used by all constructors
    private TheDocument(string[] data)
    {
        if (data.Length == 3)
            theData = data;
        else
            throw new ArgumentOutOfRangeException("data", "Data must have a length of 3");
    }

    public static implicit operator TheDocument(string[] data)
    {
        return new TheDocument(data);
    }
    public static implicit operator string[](TheDocument theDocument)
    {
        return theDocument.theData;
    }

    public string Header
    {
        get { return theData[0]; }
        set { theData[0] = value; }
    }
    public string Body
    {
        get { return theData[1]; }
        set { theData[1] = value; }
    }
    public string Footer
    {
        get { return theData[2]; }
        set { theData[2] = value; }
    }

    public void Print()
    {
        PrintTheDocument(this);
    }
    // This method handles all the printing
    public static void PrintTheDocument(TheDocument theDocument)
    {
        // ...
    }
}


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
Why are you using VB6? Do you hate yourself? (Christian Graus)

AnswerRe: OOP approach, static method Pin
PIEBALDconsult29-Jul-09 4:58
mvePIEBALDconsult29-Jul-09 4:58 
QuestionAttach User Entered Data with word Document while saving Pin
mandar77728-Jul-09 20:41
mandar77728-Jul-09 20:41 
QuestionTreeView NodeMouseHover Event Pin
vhassan28-Jul-09 20:15
vhassan28-Jul-09 20:15 
QuestionDisplay Image from Path Pin
nudma28-Jul-09 19:47
nudma28-Jul-09 19:47 
AnswerRe: Display Image from Path Pin
Christian Graus28-Jul-09 20:10
protectorChristian Graus28-Jul-09 20:10 
AnswerRe: Display Image from Path Pin
Blikkies28-Jul-09 20:14
professionalBlikkies28-Jul-09 20:14 
GeneralRe: Display Image from Path Pin
nudma28-Jul-09 21:15
nudma28-Jul-09 21:15 
GeneralRe: Display Image from Path Pin
Blue_Boy29-Jul-09 0:45
Blue_Boy29-Jul-09 0:45 
GeneralRe: Display Image from Path Pin
Blikkies29-Jul-09 1:32
professionalBlikkies29-Jul-09 1:32 
GeneralRe: Display Image from Path Pin
nudma29-Jul-09 4:08
nudma29-Jul-09 4:08 
GeneralRe: Display Image from Path Pin
Blue_Boy29-Jul-09 7:38
Blue_Boy29-Jul-09 7:38 
GeneralRe: Display Image from Path Pin
Blikkies29-Jul-09 8:26
professionalBlikkies29-Jul-09 8:26 
AnswerRe: Display Image from Path Pin
Blue_Boy28-Jul-09 20:23
Blue_Boy28-Jul-09 20:23 
AnswerRe: Display Image from Path Pin
Christian Graus28-Jul-09 21:01
protectorChristian Graus28-Jul-09 21:01 
QuestionApp with Crystal Reports Pin
CodingYoshi28-Jul-09 11:00
CodingYoshi28-Jul-09 11:00 
AnswerRe: App with Crystal Reports Pin
Ennis Ray Lynch, Jr.28-Jul-09 15:19
Ennis Ray Lynch, Jr.28-Jul-09 15:19 
GeneralRe: App with Crystal Reports Pin
N a v a n e e t h28-Jul-09 15:57
N a v a n e e t h28-Jul-09 15:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.