Click here to Skip to main content
15,894,343 members
Home / Discussions / C#
   

C#

 
AnswerRe: Serializing a Collection - Inheritance problem Pin
Pete O'Hanlon16-Jun-10 3:07
mvePete O'Hanlon16-Jun-10 3:07 
GeneralRe: Serializing a Collection - Inheritance problem Pin
lukeer16-Jun-10 4:09
lukeer16-Jun-10 4:09 
AnswerRe: Serializing a Collection - Inheritance problem Pin
Rob Graham19-Jun-10 3:21
Rob Graham19-Jun-10 3:21 
QuestionPrinting Quality Image Vs Text Pin
Anubhava Dimri16-Jun-10 0:05
Anubhava Dimri16-Jun-10 0:05 
AnswerRe: Printing Quality Image Vs Text Pin
Nuri Ismail16-Jun-10 0:26
Nuri Ismail16-Jun-10 0:26 
GeneralRe: Printing Quality Image Vs Text Pin
Anubhava Dimri17-Jun-10 20:09
Anubhava Dimri17-Jun-10 20:09 
AnswerRe: Printing Quality Image Vs Text Pin
Luc Pattyn16-Jun-10 2:25
sitebuilderLuc Pattyn16-Jun-10 2:25 
QuestionWhich is better and why? Pin
Hum Dum15-Jun-10 22:53
Hum Dum15-Jun-10 22:53 
Hi all,

I have some doubt, and it will be be help full if some one explain/elaborate on this. some variables which i am using. Whats my concern is where should i define them?


Approach 1, define with in function and modifying.
Class A
{
void CallingFunction()
{
    string data = "";
    DataTable dttemp = new DataTable();
    bool isValid = false;
    checkValue(ref data,ref isValid, ref dttemp);

    //perform some operation on data, dttemp
}

private void checkValue(ref string msg, ref bool valid, ref DataTable dttemp)
{
     msg += "Hello";
     valid = false;

     DataRow dr = dttemp.NewRow();
     dr["cID"] = "2";
     dttemp.Rows.Add(dr);
 }
}



Approach 2, define at class level.
Class A
{

DataTable dttemp;
string data = "";
bool isValid = false;

void CallingFunction()
{    
    dttemp = new DataTable();    
    checkValue();

    //perform some operation

    //reset them
    data = "";isValid = false; dttemp.Dispose();
}

private void checkValue()
{
     data += "Some data";
     isValid = true;

     DataRow dr = dttemp.NewRow();
     dr["cID"] = "2";
     dttemp.Rows.Add(dr);
 }
}


Whats the diffrence?
and when to use which?
AnswerRe: Which is better and why? Pin
Bigdeak15-Jun-10 23:22
Bigdeak15-Jun-10 23:22 
GeneralRe: Which is better and why? Pin
Hum Dum16-Jun-10 0:31
Hum Dum16-Jun-10 0:31 
AnswerRe: Which is better and why? Pin
Abhinav S16-Jun-10 0:36
Abhinav S16-Jun-10 0:36 
AnswerRe: Which is better and why? Pin
Eddy Vluggen16-Jun-10 1:15
professionalEddy Vluggen16-Jun-10 1:15 
AnswerRe: Which is better and why? Pin
PIEBALDconsult16-Jun-10 3:06
mvePIEBALDconsult16-Jun-10 3:06 
AnswerNeither approach is appropriate Pin
Ennis Ray Lynch, Jr.16-Jun-10 6:14
Ennis Ray Lynch, Jr.16-Jun-10 6:14 
GeneralRe: Neither approach is appropriate Pin
Hum Dum16-Jun-10 17:49
Hum Dum16-Jun-10 17:49 
GeneralRe: Neither approach is appropriate Pin
Ennis Ray Lynch, Jr.17-Jun-10 5:19
Ennis Ray Lynch, Jr.17-Jun-10 5:19 
Questionc++ dll in C# Pin
kk.tvm15-Jun-10 22:49
kk.tvm15-Jun-10 22:49 
AnswerRe: c++ dll in C# Pin
Pete O'Hanlon15-Jun-10 22:58
mvePete O'Hanlon15-Jun-10 22:58 
GeneralRe: c++ dll in C# Pin
kk.tvm15-Jun-10 23:15
kk.tvm15-Jun-10 23:15 
GeneralRe: c++ dll in C# Pin
Pete O'Hanlon15-Jun-10 23:39
mvePete O'Hanlon15-Jun-10 23:39 
Questionhow to create your own skin for win forms Pin
jainiraj15-Jun-10 22:48
jainiraj15-Jun-10 22:48 
AnswerRe: how to create your own skin for win forms Pin
Bigdeak15-Jun-10 23:30
Bigdeak15-Jun-10 23:30 
GeneralRe: how to create your own skin for win forms Pin
jainiraj15-Jun-10 23:31
jainiraj15-Jun-10 23:31 
GeneralRe: how to create your own skin for win forms Pin
Johnny J.16-Jun-10 0:47
professionalJohnny J.16-Jun-10 0:47 
GeneralRe: how to create your own skin for win forms Pin
Bigdeak16-Jun-10 1:38
Bigdeak16-Jun-10 1:38 

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.