Click here to Skip to main content
15,909,656 members
Home / Discussions / C#
   

C#

 
GeneralRe: Using your own classes in methods. Pin
jblouir14-Jun-07 13:26
jblouir14-Jun-07 13:26 
GeneralWell... Pin
jblouir14-Jun-07 13:31
jblouir14-Jun-07 13:31 
GeneralRe: Well... Pin
jblouir14-Jun-07 13:37
jblouir14-Jun-07 13:37 
GeneralRe: Well... Pin
jblouir14-Jun-07 13:47
jblouir14-Jun-07 13:47 
GeneralRe: Well... Pin
Christian Graus14-Jun-07 13:52
protectorChristian Graus14-Jun-07 13:52 
AnswerRe: Using your own classes in methods. Pin
Guffa14-Jun-07 13:30
Guffa14-Jun-07 13:30 
GeneralRe: Using your own classes in methods. Pin
Rudolf Jan15-Jun-07 0:27
Rudolf Jan15-Jun-07 0:27 
Questionmulti list problem [modified] Pin
bolhassanim@bellsouth.net14-Jun-07 10:34
professionalbolhassanim@bellsouth.net14-Jun-07 10:34 
I am trying to use the same class to populate the second list in my second class, but the list will have the last set of values. The only way that it work if I instantiate multiple classes, please help, why I can not use only instantiating my classes onceD'Oh! | :doh: . Here are the codes

<b><pre>First file</pre></b>
<code>
using System;
using System.Collections.Generic;
using System.Text;

namespace xpop
{
class Program
{
static void Main(string[] args)
{
_xobj xobj = new _xobj();
popxmlobj(xobj);
}
// Does work but have to instatiate the calss object twice need to re- use the calss object
static void popxmlobj1(_xobj xobj)
{
_AllValue aValue1 = new _AllValue();

aValue1.valueName = "VAL1Name";
aValue1.Values.Add("Val1");
xobj.fieldName = "FieldName1";
xobj.fieldValues.Add(aValue1);

_AllValue aValue2 = new _AllValue();
aValue2.valueName = "VAL2Name";
aValue2.Values.Add("Val2");
xobj.fieldValues.Add(aValue2);
}
// Works if I use this method
static void popxmlobj(_xobj xobj)
{
for (int i = 0; i < 2; i++)
{
if (i == 0)
{
_AllValue aValue1 = new _AllValue();

aValue1.valueName = "VAL1Name";
aValue1.Values.Add("Val1");
xobj.fieldName = "FieldName1";

xobj.fieldValues.Add(aValue1);
}

if (i == 1)
{
_AllValue aValue1 = new _AllValue();

aValue1.valueName = "VAL2Name";
aValue1.Values.Add("Val2");

xobj.fieldValues.Add(aValue1);
}
}
}
}
}
</code>

<b>pre>Second file</pre></b>
<code>
using System;
using System.Collections.Generic;
using System.Text;

namespace xpop
{
public class _xobj
{
public string fieldName;
public List<_AllValue> fieldValues = new List<_AllValue>();
}

public class _AllValue
{
public string valueName;
public List<string> Values = new List<string>();
}
}
</code>

mohsenb55


-- modified at 10:07 Friday 15th June, 2007
AnswerRe: multi list problem Pin
Christian Graus14-Jun-07 11:47
protectorChristian Graus14-Jun-07 11:47 
GeneralRe: multi list problem Pin
bolhassanim@bellsouth.net14-Jun-07 18:19
professionalbolhassanim@bellsouth.net14-Jun-07 18:19 
QuestionDelimiters - Is there a simple way Pin
haz1314-Jun-07 10:19
haz1314-Jun-07 10:19 
AnswerRe: Delimiters - Is there a simple way Pin
Paul Conrad14-Jun-07 10:31
professionalPaul Conrad14-Jun-07 10:31 
GeneralRe: Delimiters - Is there a simple way Pin
haz1314-Jun-07 10:39
haz1314-Jun-07 10:39 
GeneralRe: Delimiters - Is there a simple way Pin
Giorgi Dalakishvili14-Jun-07 10:44
mentorGiorgi Dalakishvili14-Jun-07 10:44 
GeneralRe: Delimiters - Is there a simple way Pin
Paul Conrad14-Jun-07 10:52
professionalPaul Conrad14-Jun-07 10:52 
GeneralRe: Delimiters - Is there a simple way Pin
Paul Conrad14-Jun-07 10:44
professionalPaul Conrad14-Jun-07 10:44 
GeneralRe: Delimiters - Is there a simple way Pin
haz1314-Jun-07 10:51
haz1314-Jun-07 10:51 
AnswerThe Simply Way. ;-) Pin
jblouir14-Jun-07 12:58
jblouir14-Jun-07 12:58 
GeneralRe: The Simply Way. ;-) Pin
Christian Graus14-Jun-07 13:01
protectorChristian Graus14-Jun-07 13:01 
GeneralRe: The Simply Way. ;-) Pin
jblouir14-Jun-07 13:12
jblouir14-Jun-07 13:12 
Generalbtw Haz13 Pin
jblouir14-Jun-07 13:18
jblouir14-Jun-07 13:18 
AnswerRe: Delimiters - Is there a simple way Pin
Life as a Coder14-Jun-07 19:27
Life as a Coder14-Jun-07 19:27 
QuestionA plugin for ms office Pin
Mori Nei14-Jun-07 10:14
Mori Nei14-Jun-07 10:14 
AnswerRe: A plugin for ms office Pin
ekynox14-Jun-07 12:25
ekynox14-Jun-07 12:25 
QuestionWhere to use Dataset and when to use DataTable? Pin
Khoramdin14-Jun-07 8:14
Khoramdin14-Jun-07 8:14 

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.